Open Bug 818515 Opened 13 years ago Updated 5 years ago

document.getSelection().getRangeAt(0).cloneContents() differs when .contentEditable = true/false

Categories

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

17 Branch
x86_64
All
defect

Tracking

()

UNCONFIRMED

People

(Reporter: cvenkel.miran, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Firefox/17.0 Build ID: 20121119183901 Steps to reproduce: say I have: <some cointainer contentEditable ....> <font color="blue">color</font> </some container> and select 'color' function selHTML() { /*IE works regardles of contentEditable state*/ // I allways get '<font color="blue">color</font>' if (window.ActiveXObject) { var c = document.selection.createRange(); return c.htmlText; } /*FF, it works same as IE if contentEditable = false, otherwise it returns 'color'*/ var x=document.createElement("div"); x.appendChild(document.getSelection().getRangeAt(0).cloneContents()); return x.innerHTML; } Actual results: see above comments Expected results: I think the FF stuff should work the same as IE
Could you attach a minimal testcase, please?
Flags: needinfo?(cvenkel.miran)
(In reply to Loic from comment #1) > Could you attach a minimal testcase, please? OK, working on it ...
Flags: needinfo?(cvenkel.miran)
Attached file Reporter's testcase
I think I found rules how this is not working: 1. select EXACTLY with mouse from start to end of 'color' ---> 'color' 2. Now you can deselect, reselect same as at 1 and you will get allways only 'color' 3.click drag from star of 'color', now if you drag anywhere out of 'color' text, drag/drop back to end of color text, it will work, you will get HTML
I mean in previous post, in both cases you have same selection, with different result clicking 'check ...' button on test case.
Using the latest Nightly (User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:20.0) Gecko/20121210 Firefox/20.0; Build ID: 20121210030747) and the steps from comment 5 I always get this message: <font color="blue">color</font>
Confirming that it works as described in comment #5: “color” if I selected carefully; “<font color="blue">color</font>” if I have dragged over the word edge. 2012-12-11-03-08-55-mozilla-central-firefox-20.0a1.en-US.linux-x86_64
OS: Windows 7 → All
Component: Untriaged → Selection
Product: Firefox → Core

Bulk-downgrade of unassigned, untouched DOM/Storage bug's priority.

If you have reason to believe, this is wrong, please write a comment and ni :jstutte.

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

Attachment

General

Creator:
Created:
Updated:
Size: