You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

element-closest-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-closest-polyfill - npm Package Compare versions

Comparing version

to
1.0.1

index.test.js

28

index.js

@@ -1,17 +0,15 @@

(function () {
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
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 (!Element.prototype.closest) {
Element.prototype.closest = function (s) {
var el = this;
do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
})();
do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
{
"name": "element-closest-polyfill",
"version": "1.0.0",
"version": "1.0.1",
"description": "A minimal polyfill for Element.closest",

@@ -18,3 +18,10 @@ "license": "MIT",

"package"
]
}
],
"scripts": {
"test": "jest --silent=false --verbose=true",
"prepublishOnly": "npm test"
},
"devDependencies": {
"jest": "^26.2.2"
}
}

@@ -5,3 +5,3 @@ # element-closest-polyfill

A minimal polyfill for [`Element.closest()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest), using MDN's implementation. Mostly meant for Microsoft IE.
A minimal polyfill for [`Element.closest()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest) and [`Element.matches()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches), using MDN's implementation. Mostly meant for Microsoft IE9+.

@@ -20,2 +20,2 @@ ## Install

import 'element-closest-polyfill';
```
```