getSelection, getRangeAt return wrong anchorNode, endContainer and endOffset if selection contains SVG(or unselectable text inside)
Categories
(Core :: DOM: Selection, defect, P3)
Tracking
()
Webcompat Priority | P3 |
People
(Reporter: sjorford, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: parity-chrome)
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
Steps to reproduce:
https://jsfiddle.net/sjorford/0p64nyf5/
Select some of the text, starting before the SVG image, and finishing after the SVG inage
Actual results:
Both the anchorNode and focusNode are the second text element
Expected results:
The first text element should be the anchorNode, and the second text element should be the focusNode.
Reproduced in Nightly 70.0a1 (2019-07-26) (64-bit)
Updated•6 years ago
|
Comment 1•6 years ago
|
||
The priority flag is not set for this bug.
:jwatt, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•6 years ago
|
![]() |
||
Updated•6 years ago
|
Comment 2•5 years ago
•
|
||
If the selection contains unseletable text inbetween it, the same issue occurs.
And besides anchorNode, the other two properties in the first range -- endContainer and endOffset -- are also incorrect.
See my uploaded demo.
Comment 3•5 years ago
|
||
If the selection contains unseletable text inbetween it, the same issue occurs.
And besides anchorNode,
endContainer and endOffset in the first range is also incorrect.
See my uploaded demo
Comment 4•4 years ago
•
|
||
Gecko creates two ranges, which violates the spec.
Changing Gecko to create exactly one range is presumably a lot of work.
Works with Chrome.
Updated•4 years ago
|
Comment 5•4 years ago
•
|
||
Interestingly, tapping Ctrl+a and running script to select text and an <svg>
element yields different results:
data:text/html,X<svg width="10" height="10"><g><path d="M-8-6h24v24H-8z" /></g></svg>Y<button onclick="const b = document.querySelector('body'); document.getSelection().selectAllChildren(b); document.addEventListener('selectionchange', () => console.log(document.getSelection().rangeCount));">XX</button>
Selecting text and an <svg>
element via script creates only one range.
The <path>
is in both cases not serialized.
Updated•3 years ago
|
Updated•2 years ago
|
Description
•