Skip to content

Commit

Permalink
Merge pull request #71 from plumelo/feature/NEOV-282-fix-freeze
Browse files Browse the repository at this point in the history
Fixes freeze caused by _selectDebouncer not being cancelled sometimes
  • Loading branch information
nomego authored Feb 22, 2019
2 parents cacd850 + f5e0e7a commit 5482ea8
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 89 deletions.
2 changes: 1 addition & 1 deletion cosmoz-data-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@
if (isNaN(select)) {
return;
}
this._selectDebouncer = enqueueDebouncer(Debouncer.debounce(this._selectDebouncer,
enqueueDebouncer(this._selectDebouncer = Debouncer.debounce(this._selectDebouncer,
Polymer.Async.timeOut.after(15),
() => {
this.animating = true;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"test": "test"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-html": "^5.0.0",
"eslint-plugin-mocha": "^5.2.1",
"polymer-cli": "^1.8.0",
"eslint": "^5.14.0",
"eslint-plugin-html": "^5.0.3",
"eslint-plugin-mocha": "^5.3.0",
"polymer-cli": "^1.9.6",
"web-component-tester-istanbul": "Neovici/web-component-tester-istanbul"
},
"scripts": {
Expand Down
28 changes: 28 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,34 @@
});
});

suite('navigation', () => {
let nav;

setup(done => {
nav = fixture('defaults');
nav._templatesObserver.flush();
nav.items = Array(10).fill('').map((e, i) => i.toString());
flush(done);
});

test('selects next item', () => {
nav.setItemById('0', { id: 0 });
nav.setItemById('1', { id: 1 });
nav._renderQueue();
nav._renderQueue();
const nextBtn = nav._getElement(0)
.querySelector('*')
.root.
querySelector('[cosmoz-data-nav-select="+1"]');
nextBtn.click();

assert.isOk(nav._selectDebouncer);
Polymer.flush();
assert.isTrue(nav.animating);
assert.equal(nav.selected, 1);
});
});

suite('elements buffer', () => {
let nav;

Expand Down
Loading

0 comments on commit 5482ea8

Please sign in to comment.