Fix issues with calling Polymer.Debouncer On Google hosted Gerrit the image-diff plugin is broken. The error in the js console is: `Polymer.Debouncer.debounce is not a function` This has to do with the closure compilation, where the function ends up being renamed to `Debouncer$$module$third_party$javascript$polymer$v2$polymer$lib$utils$debounce$debounce` This plugin is in maintenance mode, so we are looking for a quick fix. Apparently the debouncing is not really required and can simply be removed. I have tested this with both Bazel and Blaze builds and the Dev Helper. Google-Bug-Id: b/217942160 Release-Notes: skip Change-Id: Ie183a3c1f68e9a2c2c1cd3a374d4d0231393afa0
diff --git a/gr-resemble-diff-mode/gr-resemble-diff-mode.js b/gr-resemble-diff-mode/gr-resemble-diff-mode.js index cd0711a..372f554 100644 --- a/gr-resemble-diff-mode/gr-resemble-diff-mode.js +++ b/gr-resemble-diff-mode/gr-resemble-diff-mode.js
@@ -138,41 +138,18 @@ this.loading = false; } - // The use of debounce is to prevent the user from repeatedly calling the - // functions in a short amount of time. _handleIgnoreColorsToggle() { - this._ignoreColorsToggleJob = Polymer.Debouncer.debounce( - this._ignoreColorsToggleJob, - Polymer.Async.timeOut.after(1), - () => { - this._ignoreColors = !this._ignoreColors; - this.reload(); - } - ); + this._ignoreColors = !this._ignoreColors; + this.reload(); } _handleTransparentToggle() { - this._transparentToggleJob = Polymer.Debouncer.debounce( - this._transparentToggleJob, - Polymer.Async.timeOut.after(1), - () => { - this._transparent = !this._transparent; - this.reload(); - } - ); + this._transparent = !this._transparent; + this.reload(); } - // The wait time of 5 ms allows users to see the color change in the image - // diff relatively close to real time. Any larger wait time will not allow - // the color to show up immediately on the image diff. _handleColorChange() { - this._colorChangeJob = Polymer.Debouncer.debounce( - this._colorChangeJob, - Polymer.Async.timeOut.after(5), - () => { - this.reload(); - } - ); + this.reload(); } _hexToRGB(hex) {
diff --git a/gr-resemble-diff-mode/gr-resemble-diff-mode_test.html b/gr-resemble-diff-mode/gr-resemble-diff-mode_test.html index 43e928b..18cf465 100644 --- a/gr-resemble-diff-mode/gr-resemble-diff-mode_test.html +++ b/gr-resemble-diff-mode/gr-resemble-diff-mode_test.html
@@ -99,7 +99,6 @@ element._ignoreColors = false; assert.isFalse(element.$.ignoreColorsToggle.checked); MockInteractions.tap(element.$.ignoreColorsToggle); - element._ignoreColorsToggleJob.flush(); flushAsynchronousOperations(); assert.isTrue(element._ignoreColors); @@ -111,7 +110,6 @@ element._transparent = false; assert.isFalse(element.$.transparentToggle.checked); MockInteractions.tap(element.$.transparentToggle); - element._transparentToggleJob.flush(); flushAsynchronousOperations(); assert.isTrue(element._transparent); @@ -121,14 +119,13 @@ test('_handleColorChange', () => { sandbox.stub(element, 'reload'); element._colorValue = ''; - element._colorChangeJob.flush(); flushAsynchronousOperations(); assert.isTrue(element.reload.called); }); test('_hexToRGB', () => { - const expected = {r: 0, g: 255, b: 255}; + const expected = { r: 0, g: 255, b: 255 }; const input = '#00ffff'; const output = element._hexToRGB(input); assert.equal(output.r, expected.r); @@ -151,10 +148,8 @@ element.revisionImage = {}; assert.equal(element.reload.callCount, 1); MockInteractions.tap(element.$.ignoreColorsToggle); - element._ignoreColorsToggleJob.flush(); assert.equal(element.reload.callCount, 2); MockInteractions.tap(element.$.transparentToggle); - element._transparentToggleJob.flush(); assert.equal(element.reload.callCount, 3); }); });