vendor: amis 6.13.0 base (fork root)
This commit is contained in:
26
examples/polyfills/cloest.js
Normal file
26
examples/polyfills/cloest.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file 担心会有些浏览器不支持,所以网上抄了一段
|
||||
* @author mdn
|
||||
*/
|
||||
if (!Element.prototype.matches) {
|
||||
Element.prototype.matches =
|
||||
Element.prototype.msMatchesSelector ||
|
||||
Element.prototype.webkitMatchesSelector;
|
||||
}
|
||||
|
||||
if (!Element.prototype.closest) {
|
||||
Element.prototype.closest = function (s) {
|
||||
var el = this;
|
||||
if (!document.documentElement.contains(el)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
do {
|
||||
if (el.matches(s)) {
|
||||
return el;
|
||||
}
|
||||
el = el.parentElement;
|
||||
} while (el !== null);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user