Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only check bounding client rect on clicks that target elements #4497

Merged
merged 1 commit into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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