Comparing version 5.0.0 to 5.1.0
@@ -207,12 +207,8 @@ import { forEach } from 'min-dash'; | ||
* Remove all children from the given element. | ||
* | ||
* @param {Element} el | ||
*/ | ||
function clear(el) { | ||
el.replaceChildren(); | ||
var c; | ||
while (el.childNodes.length) { | ||
c = el.childNodes[0]; | ||
el.removeChild(c); | ||
} | ||
return el; | ||
@@ -222,32 +218,12 @@ } | ||
/** | ||
* @param { HTMLElement } element | ||
* @param { String } selector | ||
* | ||
* @return { boolean } | ||
*/ | ||
function matches(element, selector) { | ||
return element && typeof element.matches === 'function' && element.matches(selector); | ||
} | ||
/** | ||
* Closest | ||
* | ||
* @param {Element} el | ||
* @param {String} selector | ||
* @param {Boolean} checkYourSelf (optional) | ||
* @param {string} selector | ||
* @param {boolean} checkYourSelf (optional) | ||
*/ | ||
function closest(element, selector, checkYourSelf) { | ||
var currentElem = checkYourSelf ? element : element.parentNode; | ||
var actualElement = checkYourSelf ? element : element.parentNode; | ||
while (currentElem && currentElem.nodeType !== document.DOCUMENT_NODE && | ||
currentElem.nodeType !== document.DOCUMENT_FRAGMENT_NODE) { | ||
if (matches(currentElem, selector)) { | ||
return currentElem; | ||
} | ||
currentElem = currentElem.parentNode; | ||
} | ||
return matches(currentElem, selector) ? currentElem : null; | ||
return actualElement && typeof actualElement.closest === 'function' && actualElement.closest(selector) || null; | ||
} | ||
@@ -365,2 +341,12 @@ | ||
/** | ||
* @param { HTMLElement } element | ||
* @param { String } selector | ||
* | ||
* @return { boolean } | ||
*/ | ||
function matches(element, selector) { | ||
return element && typeof element.matches === 'function' && element.matches(selector) || false; | ||
} | ||
function query(selector, el) { | ||
@@ -367,0 +353,0 @@ el = el || document; |
{ | ||
"name": "min-dom", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "A minimal dom utility toolbelt", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
29938
364