1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #13144 from Snuffleupagus/GrabToPan-matches

[GrabToPan] Use `Element.matches()` rather than prefixed `...matchesSelector` versions
This commit is contained in:
Tim van der Meij 2021-03-26 21:47:32 +01:00 committed by GitHub
commit 5bb163424b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,9 +95,8 @@ GrabToPan.prototype = {
* @returns {boolean} Whether to not react to the click event.
*/
ignoreTarget: function GrabToPan_ignoreTarget(node) {
// Use matchesSelector to check whether the clicked element
// is (a child of) an input element / link
return node[matchesSelector](
// Check whether the clicked element is, a child of, an input element/link.
return node.matches(
"a[href], a[href] *, input, textarea, button, button *, select, option"
);
},
@ -178,20 +177,6 @@ GrabToPan.prototype = {
},
};
// Get the correct (vendor-prefixed) name of the matches method.
let matchesSelector;
["webkitM", "mozM", "m"].some(function (prefix) {
let name = prefix + "atches";
if (name in document.documentElement) {
matchesSelector = name;
}
name += "Selector";
if (name in document.documentElement) {
matchesSelector = name;
}
return matchesSelector; // If found, then truthy, and [].some() ends.
});
/**
* Whether the left mouse is not pressed.
* @param event {MouseEvent}