diff --git a/lib/utils/gestures.html b/lib/utils/gestures.html
index 0bdbd961c3..46d46c2687 100644
--- a/lib/utils/gestures.html
+++ b/lib/utils/gestures.html
@@ -226,6 +226,9 @@
}
function ignoreMouse(e) {
+ if (!Polymer.cancelSyntheticClickEvents) {
+ return;
+ }
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
setupTeardownMouseCanceller(true);
}
@@ -335,9 +338,11 @@
stateObj.upfn = null;
}
- // use a document-wide touchend listener to start the ghost-click prevention mechanism
- // Use passive event listeners, if supported, to not affect scrolling performance
- document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);
+ if (Polymer.cancelSyntheticClickEvents) {
+ // use a document-wide touchend listener to start the ghost-click prevention mechanism
+ // Use passive event listeners, if supported, to not affect scrolling performance
+ document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);
+ }
/**
* Module for adding listeners to a node for the following normalized
diff --git a/lib/utils/settings.html b/lib/utils/settings.html
index c27c09f99d..958ea95eee 100644
--- a/lib/utils/settings.html
+++ b/lib/utils/settings.html
@@ -122,5 +122,21 @@
Polymer.setLegacyOptimizations = function(useLegacyOptimizations) {
Polymer.legacyOptimizations = useLegacyOptimizations;
};
+
+ Polymer.cancelSyntheticClickEvents = typeof Polymer.cancelSyntheticClickEvents === 'boolean'
+ ? Polymer.cancelSyntheticClickEvents : true;
+
+ /**
+ * Sets `setCancelSyntheticEvents` globally for all elements to cancel synthetic click events
+ * fired by older mobile browsers. Modern browsers no longer fire synthetic click events, and
+ * the cancellation behavior can interfere when programmatically clicking on elements.
+ *
+ * @param {boolean} useCancelSyntheticClickEvents enable or disable cancelling synthetic
+ * events
+ * @return {void}
+ */
+ Polymer.setCancelSyntheticClickEvents = function(useCancelSyntheticClickEvents) {
+ Polymer.cancelSyntheticClickEvents = useCancelSyntheticClickEvents;
+ };
})();