Select All, Ctrl+A - does not select content of the visible <head>
Categories
(Core :: DOM: Selection, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox77 | --- | affected |
People
(Reporter: sergeykish, Unassigned)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
Steps to reproduce:
I've displayed <head>
, <title>
, <script>
and <style>
with CSS
head, title,script, style { display: block }
Ctrl+A or Edit / Select All
Actual results:
it selects <body>
content
Expected results:
It should select all visible text content (including <head>
)
Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
For reference, this is the problematic check. However that's not enough, and that selection can't be copied, so needs more digging.
We should probably remove most of these assumptions of "<body>
is the root in html documents".
Updated•4 years ago
|
Reporter | ||
Comment 2•4 years ago
|
||
anchorNode
and focusNode
not text
but <body>
getSelection()
Selection { anchorNode: body, anchorOffset: 0, focusNode: body, focusOffset: 6, isCollapsed: false, rangeCount: 1, type: "Range", caretBidiLevel: 0 }
getSelection().toString() is body content
In contrast Chrome selects all but
getSelection()
Selection { anchorNode: text, anchorOffset: 0, baseNode: text, baseOffset: 0, extentNode: body, extentOffset: 0, focusNode: body, focusOffset: 0, isCollapsed: false, rangeCount: 1, type: "Range" }
focusNode
is <body>
and
getSelection().toString()
"Select All in <head>, <title>, <script> <style>
//foo
/* foo */
"
does not include <body>
Reporter | ||
Comment 3•4 years ago
|
||
Firefox 77 selects all text
getSelection()
Selection { anchorNode: html, anchorOffset: 0, focusNode: html, focusOffset: 2, isCollapsed: false, rangeCount: 1, type: "Range", caretBidiLevel: null }
Looks right, but
getSelection().toString()
"<html contenteditable> Select All
Ctrl + A or Edit > Select All"
No <head>
content and I don't know where it got newlines.
Oh, it does not matter if <head>
is visible
Reporter | ||
Comment 4•4 years ago
|
||
But for same html-contenteditable-select-all-test.htm
getSelection().getRangeAt(0).toString()
"<html contenteditable> Select Allhead, title, style, script { display: block }//foo<html contenteditable> Select AllCtrl + A or Edit > Select All"
different
Reporter | ||
Comment 5•4 years ago
|
||
Where is getSelection().toString()
implementation?
Maybe
https://searchfox.org/mozilla-central/source/dom/base/Selection.cpp#273
https://searchfox.org/mozilla-central/source/dom/base/nsDocumentEncoder.cpp
Comment 6•4 years ago
|
||
The first one.
Reporter | ||
Comment 7•4 years ago
|
||
It really is broken
getSelection().selectAllChildren(document.documentElement)
getSelection().toString()
"<html contenteditable> Select All
Ctrl + A or Edit > Select All"
That is a blocker
Updated•4 years ago
|
Description
•