ES6ify /gr-patch-range-select/*
Bug: Issue 6179
Change-Id: I9285ea11f9ff63244f1321cc5a3ba8466db56ae8
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
index 58d29bd..e9437bd 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
@@ -15,7 +15,7 @@
'use strict';
// Maximum length for patch set descriptions.
- var PATCH_DESC_MAX_LENGTH = 500;
+ const PATCH_DESC_MAX_LENGTH = 500;
Polymer({
is: 'gr-patch-range-select',
@@ -36,15 +36,15 @@
behaviors: [Gerrit.PatchSetBehavior],
- _updateSelected: function() {
+ _updateSelected() {
this._rightSelected = this.patchRange.patchNum;
this._leftSelected = this.patchRange.basePatchNum;
},
- _handlePatchChange: function(e) {
- var leftPatch = this._leftSelected;
- var rightPatch = this._rightSelected;
- var rangeStr = rightPatch;
+ _handlePatchChange(e) {
+ const leftPatch = this._leftSelected;
+ const rightPatch = this._rightSelected;
+ let rangeStr = rightPatch;
if (leftPatch != 'PARENT') {
rangeStr = leftPatch + '..' + rangeStr;
}
@@ -52,11 +52,11 @@
e.target.blur();
},
- _computeLeftDisabled: function(patchNum, patchRange) {
+ _computeLeftDisabled(patchNum, patchRange) {
return parseInt(patchNum, 10) >= parseInt(patchRange.patchNum, 10);
},
- _computeRightDisabled: function(patchNum, patchRange) {
+ _computeRightDisabled(patchNum, patchRange) {
if (patchRange.basePatchNum == 'PARENT') { return false; }
return parseInt(patchNum, 10) <= parseInt(patchRange.basePatchNum, 10);
},
@@ -66,16 +66,16 @@
// are loaded, the correct value will get selected. I attempted to
// debounce these, but because they are detecting two different
// events, sometimes the timing was off and one ended up missing.
- _synchronizeSelectionRight: function() {
+ _synchronizeSelectionRight() {
this.$.rightPatchSelect.value = this._rightSelected;
},
- _synchronizeSelectionLeft: function() {
+ _synchronizeSelectionLeft() {
this.$.leftPatchSelect.value = this._leftSelected;
},
- _computePatchSetDescription: function(revisions, patchNum) {
- var rev = this.getRevisionByPatchNum(revisions, patchNum);
+ _computePatchSetDescription(revisions, patchNum) {
+ const rev = this.getRevisionByPatchNum(revisions, patchNum);
return (rev && rev.description) ?
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
},
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html
index 00d73bf..0195eac 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html
@@ -34,24 +34,24 @@
</test-fixture>
<script>
- suite('gr-patch-range-select tests', function() {
- var element;
+ suite('gr-patch-range-select tests', () => {
+ let element;
- setup(function() {
+ setup(() => {
element = fixture('basic');
});
- test('enabled/disabled options', function() {
- var patchRange = {
+ test('enabled/disabled options', () => {
+ const patchRange = {
basePatchNum: 'PARENT',
patchNum: '3',
};
- ['1', '2', '3'].forEach(function(patchNum) {
+ for (const patchNum of ['1', '2', '3']) {
assert.isFalse(element._computeRightDisabled(patchNum, patchRange));
- });
- ['PARENT', '1', '2'].forEach(function(patchNum) {
+ }
+ for (const patchNum of ['PARENT', '1', '2']) {
assert.isFalse(element._computeLeftDisabled(patchNum, patchRange));
- });
+ }
assert.isTrue(element._computeLeftDisabled('3', patchRange));
patchRange.basePatchNum = '2';
@@ -61,11 +61,11 @@
assert.isFalse(element._computeRightDisabled('3', patchRange));
});
- test('navigation', function(done) {
- var showStub = sinon.stub(page, 'show');
- var leftSelectEl = element.$.leftPatchSelect;
- var rightSelectEl = element.$.rightPatchSelect;
- var blurSpy = sinon.spy(leftSelectEl, 'blur');
+ test('navigation', done => {
+ const showStub = sinon.stub(page, 'show');
+ const leftSelectEl = element.$.leftPatchSelect;
+ const rightSelectEl = element.$.rightPatchSelect;
+ const blurSpy = sinon.spy(leftSelectEl, 'blur');
element.changeNum = '42';
element.path = 'path/to/file.txt';
element.availablePatches = ['1', '2', '3'];
@@ -75,8 +75,8 @@
};
flushAsynchronousOperations();
- var numEvents = 0;
- leftSelectEl.addEventListener('change', function(e) {
+ let numEvents = 0;
+ leftSelectEl.addEventListener('change', e => {
numEvents++;
if (numEvents == 1) {
assert(showStub.lastCall.calledWithExactly(
@@ -98,23 +98,23 @@
element.fire('change', {}, {node: leftSelectEl});
});
- test('filesWeblinks', function() {
+ test('filesWeblinks', () => {
element.filesWeblinks = {
meta_a: [
{
name: 'foo',
url: 'f.oo',
- }
+ },
],
meta_b: [
{
name: 'bar',
url: 'ba.r',
- }
+ },
],
};
flushAsynchronousOperations();
- var domApi = Polymer.dom(element.root);
+ const domApi = Polymer.dom(element.root);
assert.equal(
domApi.querySelector('a[href="f.oo"]').textContent, 'foo');
assert.equal(