Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
more descriptive tests. Make passive: false explicit.
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Oct 4, 2016
1 parent 6a9a411 commit 57650d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions iron-dropdown-scroll-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,23 @@
this._boundScrollHandler = this._boundScrollHandler ||
this._scrollInteractionHandler.bind(this);
// Modern `wheel` event for mouse wheel scrolling:
document.addEventListener('wheel', this._boundScrollHandler, true);
document.addEventListener('wheel', this._boundScrollHandler, {capture: true, passive: false});
// Older, non-standard `mousewheel` event for some FF:
document.addEventListener('mousewheel', this._boundScrollHandler, true);
document.addEventListener('mousewheel', this._boundScrollHandler, {capture: true, passive: false});
// IE:
document.addEventListener('DOMMouseScroll', this._boundScrollHandler, true);
document.addEventListener('DOMMouseScroll', this._boundScrollHandler, {capture: true, passive: false});
// Save the SCROLLABLE_NODES on touchstart, to be used on touchmove.
document.addEventListener('touchstart', this._boundScrollHandler, true);
document.addEventListener('touchstart', this._boundScrollHandler, {capture: true, passive: false});
// Mobile devices can scroll on touch move:
document.addEventListener('touchmove', this._boundScrollHandler, true);
document.addEventListener('touchmove', this._boundScrollHandler, {capture: true, passive: false});
},

_unlockScrollInteractions: function() {
document.removeEventListener('wheel', this._boundScrollHandler, true);
document.removeEventListener('mousewheel', this._boundScrollHandler, true);
document.removeEventListener('DOMMouseScroll', this._boundScrollHandler, true);
document.removeEventListener('touchstart', this._boundScrollHandler, true);
document.removeEventListener('touchmove', this._boundScrollHandler, true);
document.removeEventListener('wheel', this._boundScrollHandler, {capture: true, passive: false});
document.removeEventListener('mousewheel', this._boundScrollHandler, {capture: true, passive: false});
document.removeEventListener('DOMMouseScroll', this._boundScrollHandler, {capture: true, passive: false});
document.removeEventListener('touchstart', this._boundScrollHandler, {capture: true, passive: false});
document.removeEventListener('touchmove', this._boundScrollHandler, {capture: true, passive: false});
},

/**
Expand Down
18 changes: 9 additions & 9 deletions test/iron-dropdown-scroll-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@
test('prevents wheel events from locked elements', function() {
events.forEach(function(event) {
childTwo.dispatchEvent(event);
expect(event.defaultPrevented).to.be.eql(true);
assert.isTrue(event.defaultPrevented, event.type + ' ok');
});
});

test('allows wheel events when there are no locking elements', function() {
Polymer.IronDropdownScrollManager.removeScrollLock(childOne);
events.forEach(function(event) {
childTwo.dispatchEvent(event);
expect(event.defaultPrevented).to.be.eql(false);
assert.isFalse(event.defaultPrevented, event.type + ' ok');
});
});

test('allows wheel events from unlocked elements', function() {
events.forEach(function(event) {
childOne.dispatchEvent(event);
expect(event.defaultPrevented).to.be.eql(false);
assert.isFalse(event.defaultPrevented, event.type + ' ok');
});
});

Expand All @@ -150,7 +150,7 @@
composed: true
});
childTwo.dispatchEvent(event);
expect(event.defaultPrevented).to.be.eql(true);
assert.isTrue(event.defaultPrevented, event.type + ' ok');
});

test('touchstart is not prevented if dispatched by an element inside the locking element', function() {
Expand All @@ -160,7 +160,7 @@
composed: true
});
grandChildOne.dispatchEvent(event);
expect(event.defaultPrevented).to.be.eql(false);
assert.isFalse(event.defaultPrevented, event.type + ' ok');
});

test('arrow keyboard events not prevented by manager', function() {
Expand All @@ -176,10 +176,10 @@
grandChildOne.dispatchEvent(up);
grandChildOne.dispatchEvent(right);
grandChildOne.dispatchEvent(down);
expect(left.defaultPrevented).to.be.eql(false);
expect(up.defaultPrevented).to.be.eql(false);
expect(right.defaultPrevented).to.be.eql(false);
expect(down.defaultPrevented).to.be.eql(false);
assert.isFalse(left.defaultPrevented, 'left ok');
assert.isFalse(up.defaultPrevented, 'up ok');
assert.isFalse(right.defaultPrevented, 'right ok');
assert.isFalse(down.defaultPrevented, 'down ok');
});
});
});
Expand Down

0 comments on commit 57650d9

Please sign in to comment.