]> git.mxchange.org Git - friendica.git/commitdiff
Add global Javascript Element.matches polyfill
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 3 Jun 2019 12:30:24 +0000 (08:30 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 3 Jun 2019 12:30:24 +0000 (08:30 -0400)
view/js/main.js

index cd09de014376e36a946c1c790ad867abcab50082..a2e2698a821730dd81653f97781294bd21143dd2 100644 (file)
@@ -1,4 +1,21 @@
 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
+
+// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
+if (!Element.prototype.matches) {
+       Element.prototype.matches =
+               Element.prototype.matchesSelector ||
+               Element.prototype.mozMatchesSelector ||
+               Element.prototype.msMatchesSelector ||
+               Element.prototype.oMatchesSelector ||
+               Element.prototype.webkitMatchesSelector ||
+               function(s) {
+                       var matches = (this.document || this.ownerDocument).querySelectorAll(s),
+                               i = matches.length;
+                       while (--i >= 0 && matches.item(i) !== this) {}
+                       return i > -1;
+               };
+}
+
 function resizeIframe(obj) {
        _resizeIframe(obj, 0);
 }