Fix "TypeError: Cannot read property 'hasAttribute' of null" when loading on cached pages

Follow-up to c4de603ef9.

Change-Id: I05dfb142e95e02715b56c2bd7c73bcfbb342fbfe
This commit is contained in:
Bartosz Dziewoński 2021-03-22 21:06:34 +01:00
parent 536f50c293
commit f727c988a0

View file

@ -85,7 +85,8 @@ ThreadItem.static.newFromJSON = function ( json, commentsById ) {
idEscaped = $.escapeSelector( item.id ); idEscaped = $.escapeSelector( item.id );
item.range = { item.range = {
startContainer: document.getElementById( item.id ), // Check old selector for compatibility with cached HTML
startContainer: document.getElementById( item.id ) || document.querySelector( '[data-mw-comment-start="' + idEscaped + '"]' ),
startOffset: 0, startOffset: 0,
endContainer: document.querySelector( '[data-mw-comment-end="' + idEscaped + '"]' ), endContainer: document.querySelector( '[data-mw-comment-end="' + idEscaped + '"]' ),
endOffset: 0 endOffset: 0