Follow-up: Adjust comment ranges to exclude the start marker *only*

The modifier crashes if endContainer is a <p>/<dd>/<li> node, and
it often is if we try to exclude the end marker from the range.
It doesn't matter for T281471, so let's just leave it that way.
(This is also more similar to the range produced by our parser.)

Follow-up to c4ba8e921a. No idea how
I missed this when testing that patch.

Also, improve comments.

Bug: T281471
Change-Id: If6aba34acf29c37d06fb0ca92547f78b58695597
This commit is contained in:
Bartosz Dziewoński 2021-05-27 21:28:28 +02:00
parent c4ba8e921a
commit 7b21e29405

View file

@ -93,10 +93,12 @@ ThreadItem.static.newFromJSON = function ( json, commentsById ) {
var endMarker = document.querySelector( '[data-mw-comment-end="' + idEscaped + '"]' );
item.range = {
// Start range after startMarker, because it produces funny results from getBoundingClientRect
startContainer: startMarker.parentNode,
startOffset: utils.childIndexOf( startMarker ) + 1,
endContainer: endMarker.parentNode,
endOffset: utils.childIndexOf( endMarker )
// End range inside endMarker, because modifier crashes if endContainer is a <p>/<dd>/<li> node
endContainer: endMarker,
endOffset: 0
};
// Setup replies/parent pointers