Last Comment Bug 763383 - execCommand("delete") doesn´t remove empty span-elements
: execCommand("delete") doesn´t remove empty span-elements
Product: Core
Classification: Components
Component: Editor (show other bugs)
: 13 Branch
: x86 Windows XP
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Makoto Kato [:m_kato]
Depends on:
  Show dependency treegraph
Reported: 2012-06-10 23:44 PDT by friba77
Modified: 2012-06-12 01:08 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image friba77 2012-06-10 23:44:18 PDT
User Agent: Opera/9.80 (Windows NT 5.1; U; de) Presto/2.10.229 Version/11.64

Steps to reproduce:

Entered two characters, selected both of them and changed them to bold with execCommand("bold"). The result was:
<span _moz_dirty="" style="font-weight: bold;">xy</span>
Then i set caret and deleted both characters with the delete-key.

Actual results:

The empty span-element hasn´t been deleted. The result is:
<span style="font-weight: bold;"></span>

Expected results:

Empty span-elements should be deleted recursively.
Comment 1 User image Loic 2012-06-11 08:46:03 PDT
Demo to test:
Comment 2 User image friba77 2012-06-12 00:38:42 PDT
I don´t know why, but there are different results.

midasdemo: a<strong>bc</strong>d
my own testscript: a<span style="font-weight: bold;">bc</span>d

Your testpage also shows another problem with execCommand:

1) type in: abc
2) delete these characters with the delete-key

Then switch to 'View HTML Source'. You will find a <br>. This <br> is inserted as soon as you delete the last character.
Comment 3 User image friba77 2012-06-12 00:51:54 PDT
My function to get a text bold:
function command(command) {
   try {
      if (isSelected()) {
         if (!execCommand)
            throw new Error(errorNotIn);
         if (!document.execCommand(command, false, null))
            throw new Error(errorFalse);
      else alert(errorRange);
   catch(error) {
input type="button" value="fett" onclick="editor.command('bold');" />

This creates <span style="font-weight: bold;"> elements.
Comment 4 User image friba77 2012-06-12 01:06:11 PDT
I have found a difference between our scripts. I work with:
<div id="editor" contenteditable="true"></div>
And you work with:
<iframe id="edit" width="100%" height="200px"></iframe>

I think this is the reason why we get different results.
Comment 5 User image friba77 2012-06-12 01:08:31 PDT
And i think thats also the reason for my problem. See my first entry (description).

Note You need to log in before you can comment on or make changes to this bug.