Open Bug 496649 Opened 15 years ago Updated 3 years ago

Input caret moves to end when setting innerHTML of another element

Categories

(Core :: DOM: Editor, defect, P5)

defect

Tracking

()

People

(Reporter: yoah, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 GTBDFff GTB5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 GTBDFff GTB5

The input caret in an input field sometimes moves to the end of the text when setting the innerHTML of some other element. The example I have is setting the innerHTML to be a table (moves the caret), while setting to something else (span) foes not move the caret.


Reproducible: Always

Steps to Reproduce:
1. Open page http://www.calcoolate.com/ffcaretbug.html
2. Click the input field to move the caret to anywhere in the middle of the text
3. Click the "simple text" link and notice that the caret remains in place
4. Click the "table" link and notice that the caret moves to the end of the text


Expected Results:  
The caret should not move in step 4.

happens also in the latest 3.5 beta.
Component: General → Editor
Product: Firefox → Core
QA Contact: general → editor
This is because you're trying to generate invalid HTML - when you click "table" you put table element into inline element which is forbidden
Replace span#msg with div#msg and it will be ok
Thanks! Changing span to div indeed solved the problem. It is strange that the caret moves for this reason, it does not happen in other browsers or FF versions before 3, but for me this is good enough.
Severity: normal → minor
See bug 500905, comment 10 for what is needed to fix this.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: x86 → All
Attached file reporter's testcase
A copy of the reporter's testcase in case it goes away.

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: minor → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: