From: Kosta Harlan Date: Fri, 29 Jun 2018 18:58:03 +0000 (-0400) Subject: RC Filters: Avoid unnecessary update events when clearing highlight X-Git-Tag: 1.34.0-rc.0~4890^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=830efff4fc1cade606eecdaa1f7f78e0dc5e1226;p=lhc%2Fweb%2Fwiklou.git RC Filters: Avoid unnecessary update events when clearing highlight The strict equality check just below the lines added in this commit will fail if the Item's highlightColor is null/undefined, and if the incoming parameter is null. This situation happens when mw.rcfilters.dm.ItemModel.prototype.clearHighlightColor is called when updating the state from the query parameters. By returning early we can avoid emitting update events for every filter item. Bug: T198359 Change-Id: Ia3e5f333964545c7f33777be915389728c03eace --- diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js index d1e40cad90..fef52264e4 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js @@ -207,6 +207,10 @@ if ( !this.isHighlightSupported() ) { return; } + // If the highlight color on the item and in the parameter is null/undefined, return early. + if ( !this.highlightColor && !highlightColor ) { + return; + } if ( this.highlightColor !== highlightColor ) { this.highlightColor = highlightColor;