Skip to content

Commit

Permalink
Merge pull request #4497 from Polymer/fix-gesture-targeting
Browse files Browse the repository at this point in the history
Only check bounding client rect on clicks that target elements
  • Loading branch information
Steve Orvell authored Apr 4, 2017
2 parents 72311c6 + af37d04 commit d995526
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
// the bounding box of the target of the event
// Thanks IE 10 >:(
let t = Gestures._findOriginalTarget(ev);
// make sure the target of the event is an element so we can use getBoundingClientRect,
// if not, just assume it is a synthetic click
if (t.nodeType !== Node.ELEMENT_NODE) {
return true;
}
let bcr = t.getBoundingClientRect();
// use page x/y to account for scrolling
let x = ev.pageX, y = ev.pageY;
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,16 @@
assert.equal(el[key], 'pan-y');
})
});

suite('Regression Testing', function() {
test('#4459', function() {
Polymer.Gestures.add(document, 'tap', null);
document.dispatchEvent(new MouseEvent('mousedown', { detail: 1, clientX: -100, bubbles: true, composed: true }));
document.dispatchEvent(new MouseEvent('mouseup', { detail: 1, clientX: 100, bubbles: true, composed: true }));
document.dispatchEvent(new MouseEvent('click', { detail: 1, clientX: 100, bubbles: true, composed: true }));
Polymer.Gestures.remove(document, 'tap', null);
});
})
</script>

</body>
Expand Down

0 comments on commit d995526

Please sign in to comment.