mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
31 lines
864 B
JavaScript
31 lines
864 B
JavaScript
(function(){
|
|
"use strict";
|
|
|
|
if (typeof Element.prototype.matches !== 'function') {
|
|
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector || function matches(selector) {
|
|
var element = this;
|
|
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
|
|
var index = 0;
|
|
while (elements[index] && elements[index] !== element) {
|
|
++index;
|
|
}
|
|
return Boolean(elements[index]);
|
|
};
|
|
}
|
|
|
|
|
|
if (typeof Element.prototype.closest !== 'function') {
|
|
Element.prototype.closest = function closest(selector) {
|
|
var element = this;
|
|
while (element && element.nodeType === 1) {
|
|
if (element.matches(selector)) {
|
|
return element;
|
|
}
|
|
element = element.parentNode;
|
|
}
|
|
return null;
|
|
};
|
|
}
|
|
|
|
})();
|