Open Bug 1158555 Opened 9 years ago Updated 4 years ago

Selection API is inconsistent with chrome and ie in some languages


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

37 Branch





(Reporter: tonpo.vesham, Unassigned)


(Keywords: intl, testcase)


(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36

Steps to reproduce:

Given the followig div:
<div id='textDiv'>हालाँकि</div>

var domElem = document.getElementById('textDiv');
var sel = getSelection();
var textNode = domElem.childNodes[0];



Actual results:

In firefox (version 37.0.2 on windows 8.1 64bit and ie, ver 11.096), despite that visually there are 2 characters selected, the first sentence gives 1.

the second gives 0.

Expected results:

For the first sentence:

in chrome (42.0.2311.90 on windows), when I do

I get 2, and it's ok because the selection visually selects 2 characters (one of them is a combining mark).

Maybe there should be another method to get the same effect, however there should be a consistency.

for the second sentence I should got the actual select width.
In ie, I actually used addRange() because its 'Selection' objects has no 'extend' method
Component: Untriaged → Selection
Keywords: intl, testcase
Product: Firefox → Core
Attached file testcase.html
It's worth to say that in input element setSelectionRanage() method the browsers(chrome and firefox) behave similar.

I don't know if it's relevant but in the specification of setSelectionRange() for input element, there is the following statement:
"Characters with no visible rendering, such as U+
200D ZERO WIDTH JOINER, still count as characters. Thus, for instance, the selection can include just an invisible character, and the text insertion cursor can be placed to one side or another of such a character."

And it's sound that in the input element the grapheme breaking is not took into account when selecting.

On the other hand, in svg text selectSubString method the specification say

'void selectSubString(in unsigned long charnum, in unsigned long nchars)
Causes the specified substring to be selected just as if the user selected the substring interactively.'

and chrome and firefox behaves completely different for the following code:

<svg height="30" width="200">
  <text id="t" x="0" y="15" fill="red">हालाँकि</text>

then when i put the following lines in the console:
var t=document.getElementById('t');

the two browsers select completely  different characters!
Attached file testcase_SVG.html

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: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.