UNPKG

690 BJavaScriptView Raw
1"use strict";
2
3(function () {
4 var methodNames = ["matches", "webkitMatchesSelector", "mozMatchesSelector", "msMatchesSelector", "oMatchesSelector"];
5 var i;
6
7 if (typeof Element.prototype.matches === "function") {
8 return;
9 }
10
11 for (i = 0; i < methodNames.length; i++) {
12 if (typeof Element.prototype[methodNames[i]] === "function") {
13 Object.defineProperty(Element.prototype, "matches", {
14 enumerable: false,
15 writable: true,
16 value: Element.prototype[methodNames[i]]
17 });
18 return;
19 }
20 }
21
22 throw new Error("No polyfill for Element.prototype.matches available");
23})();