Open Bug 656626 Opened 13 years ago Updated 2 years ago

innerHTML reports a superfluous HTMLBRElement after editing a heading with contenteditable set to true

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

People

(Reporter: klaus.foerster, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [h2review-noted])

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Build Identifier: Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

When you edit a heading that has its contenteditable attribute set to true and add spaces at its end, an extra HTMLBRElement is reported by innerHTML after the last space. Once it is added, there is no way to get rid of it anymore. When you add characters instead of spaces, no HTMLBRElement is added.

Reproducible: Always

Steps to Reproduce:
follow instructions at URL that demonstrates the problem

Actual Results:  
one HTMLBRElement is reported at the end of the string

Expected Results:  
no HTMLBRElement should be reported at all
Reproduced.
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110513 Firefox/6.0a1
Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Mozilla/5.0 (Windows NT 6.0; rv:6.0a1) Gecko/20110514 Firefox/6.0a1
OS: Linux → All
Hardware: x86 → All
Version: unspecified → Trunk
I attached the testcase in case it gets deleted from the web server.
Status: UNCONFIRMED → NEW
Component: General → Editor
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → editor
Boris, do you think that the HTML encoder should treat the bogus BR node especially (by excluding it from the output)?
That would be pretty odd... and also the bogus BR node is in the DOM anyway, no?  So you can detect its presence in other ways.

Can we somehow avoid putting it there to start with?
(In reply to comment #4)
> Can we somehow avoid putting it there to start with?

I will hopefully remove it some day, but that's a rather large project...
In that case, I wouldn't worry too much about this bug for now....

… and 8 years later, this bug is still around. This also applies to block elements like <p>, resulting in quite some messed up HTML markup.

<div contenteditable="true"><p>Test</p></div>

Adding a space after "Test" yields a <br> too, regardless of any content before or after that <p>.

Whiteboard: [h2review-noted]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: