Currently, getTargetRanges() is defined as:
getTargetRanges() returns an arrays StaticRanges that will be affected by the event if it is not cancelled.
https://w3c.github.io/input-events/#dom-inputevent-gettargetranges
InputEvent.getTargetRanges(): returns an arrays of StaticRanges which will be affected by the change to the DOM if it is not canceled.
https://w3c.github.io/input-events/#event-type-beforeinput
Currently, I'm implementing computation of "affected ranges" for shipping beforeinput event of Firefox. However, this definition is really unclear.
For example, when Backspaceing in <p>abc</p><p>[]def</p>, then, the paragraphs will be joined so that ("abc", 3) - ("def", 0) must be expected by web apps even though new empty first or second <p> element is removed (i.e., affected).
Another example: when there is invisible white-spaces at start of second paragraph and/or end of first paragraph in the previous example, i.e., <p>abc </p><p> []def</p>, browsers removes the invisible white-spaces too, i.e., becomes <p>abcdef</p>. So, in this case, getTargetRanges() should include the invisible white-spaces, but at least Blink does not include the invisible white-spaces.
On the other hand, if there is an invisible <br> element in the first paragraph, i.e., in the case of <p>abc<br></p><p>[]def</p>, Blink returns (p, 1) - (p, 0). I.e., including the invisible <br> element.
So, at least the first example, "affect range" may not be good information which web apps want to know. However, at the latter 2 cases, invisible things which will be removed should be contained by the result of getTargetRanges().
Currently,
getTargetRanges()is defined as:Currently, I'm implementing computation of "affected ranges" for shipping
beforeinputevent of Firefox. However, this definition is really unclear.For example, when
Backspaceing in<p>abc</p><p>[]def</p>, then, the paragraphs will be joined so that("abc", 3)-("def", 0)must be expected by web apps even though new empty first or second<p>element is removed (i.e., affected).Another example: when there is invisible white-spaces at start of second paragraph and/or end of first paragraph in the previous example, i.e.,
<p>abc </p><p> []def</p>, browsers removes the invisible white-spaces too, i.e., becomes<p>abcdef</p>. So, in this case,getTargetRanges()should include the invisible white-spaces, but at least Blink does not include the invisible white-spaces.On the other hand, if there is an invisible
<br>element in the first paragraph, i.e., in the case of<p>abc<br></p><p>[]def</p>, Blink returns(p, 1) - (p, 0). I.e., including the invisible<br>element.So, at least the first example, "affect range" may not be good information which web apps want to know. However, at the latter 2 cases, invisible things which will be removed should be contained by the result of
getTargetRanges().