From 990a9cc828baa1e3851fabc2faf847f5dd65ba13 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Wed, 18 Oct 2023 15:31:36 +0200 Subject: [PATCH] Fix certain history events being triggered multiple times See T349208 for an explanation. It looks like the SliderView.render function was written with the assumption that it's only triggered once on construction time. But since T139101 it's triggered again for every window resize event. This adds the same event handlers over and over again to existing elements that aren't affected by the SliderView.render function. This will probably become even worse with I49878fd (T336729). Please test this carefully. I'm not 100% sure this is the best possible fix. Bug: T349208 Change-Id: Iba22924b660f2709c0680aa6fbeb0feba92cfa76 --- modules/ext.RevisionSlider.SliderView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ext.RevisionSlider.SliderView.js b/modules/ext.RevisionSlider.SliderView.js index fe117e76..9665f4bc 100644 --- a/modules/ext.RevisionSlider.SliderView.js +++ b/modules/ext.RevisionSlider.SliderView.js @@ -17,6 +17,8 @@ const DiffPage = require( './ext.RevisionSlider.DiffPage.js' ), function SliderView( slider ) { this.slider = slider; this.diffPage = new DiffPage( this.slider.getRevisionList() ); + this.diffPage.addHandlersToCoreLinks( this ); + this.diffPage.initOnPopState( this ); } $.extend( SliderView.prototype, { @@ -110,9 +112,7 @@ $.extend( SliderView.prototype, { $container.empty().append( this.$element ); this.slideView( Math.floor( ( this.getNewerPointerPos() - 1 ) / this.slider.getRevisionsPerWindow() ), 0 ); - this.diffPage.addHandlersToCoreLinks( this ); this.diffPage.replaceState( mw.config.get( 'wgDiffNewId' ), mw.config.get( 'wgDiffOldId' ), this ); - this.diffPage.initOnPopState( this ); }, /**