Open Bug 1246519 Opened 5 years ago Updated 2 years ago

document.queryCommandValue doesn't reflect the change after executing backColor [contenteditable, execCommand]


(Core :: DOM: Editor, defect)

47 Branch
Not set





(Reporter: cyril.auburtin, Unassigned)


(Whiteboard: dom-triaged)


(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160205030204

Steps to reproduce:

after executing backColor,
in console, we see no changes in document.queryCommandValue('backColor');

I guess maybe it's because the selection is oustide the span |<span style="">...</span>|

(similar issue

Actual results:

no changes in commandValue('backColor')

Expected results:

it should be updated (it works for foreColor)

(attached screen capture, on the left Chrome, on the right FF)
Component: Untriaged → Editor
Product: Firefox → Core
After applying the 'backColor' command, the selected range is updated to start from the end of the text node just before the colored span and end at the end of the text node that is in the colored span. The code that queries the background color [1] checks the color at the start of the selected range which is not inside the span and thus does not return the color you are expecting.

A possible fix could be to update the selected range to be entirely within the inline style when an exec command applies an inline style. Another simpler fix could to be check the color at the end of the selected range. 

Whiteboard: dom-triaged

No, the real bug is that neither backColor nor hiliteColor return correct value in FF:

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