mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Merge "highlighter: Ensure items in .ranges and .$element are in the same order"
This commit is contained in:
commit
90018a5b55
|
@ -10,10 +10,9 @@ var
|
|||
* @param {CommentItem|CommentItem[]} comments Comment item(s) to highlight
|
||||
*/
|
||||
function Highlight( comments ) {
|
||||
var highlight = this;
|
||||
var highlightNodes = [];
|
||||
var ranges = [];
|
||||
|
||||
this.ranges = [];
|
||||
this.$element = $( [] );
|
||||
this.topmostElement = null;
|
||||
|
||||
comments = Array.isArray( comments ) ? comments : [ comments ];
|
||||
|
@ -30,10 +29,13 @@ function Highlight( comments ) {
|
|||
// before, otherwise Node#getBoundingClientRect() returns wrong results.
|
||||
range.insertNode( $highlight[ 0 ] );
|
||||
|
||||
highlight.ranges.push( range );
|
||||
highlight.$element = highlight.$element.add( $highlight );
|
||||
ranges.push( range );
|
||||
highlightNodes.push( $highlight[ 0 ] );
|
||||
} );
|
||||
|
||||
this.ranges = ranges;
|
||||
this.$element = $( highlightNodes );
|
||||
|
||||
// Events
|
||||
this.updateDebounced = OO.ui.debounce( this.update.bind( this ), 500 );
|
||||
window.addEventListener( 'resize', this.updateDebounced );
|
||||
|
|
Loading…
Reference in a new issue