Comparing version 4.1.0 to 4.2.0
@@ -19,5 +19,7 @@ function _mergeNamespaces(n, m) { | ||
* | ||
* @param {Array<?>} arr | ||
* @template T | ||
* | ||
* @return {Array<?>} | ||
* @param {T[][] | T[] | null} [arr] | ||
* | ||
* @return {T[]} | ||
*/ | ||
@@ -53,6 +55,7 @@ | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
* @return {T} return result that stopped the iteration | ||
*/ | ||
@@ -281,12 +284,8 @@ function forEach(collection, iterator) { | ||
* 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; | ||
@@ -296,32 +295,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; | ||
} | ||
@@ -552,2 +531,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) { | ||
@@ -554,0 +543,0 @@ el = el || document; |
@@ -23,5 +23,7 @@ 'use strict'; | ||
* | ||
* @param {Array<?>} arr | ||
* @template T | ||
* | ||
* @return {Array<?>} | ||
* @param {T[][] | T[] | null} [arr] | ||
* | ||
* @return {T[]} | ||
*/ | ||
@@ -57,6 +59,7 @@ | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
* @return {T} return result that stopped the iteration | ||
*/ | ||
@@ -285,12 +288,8 @@ function forEach(collection, iterator) { | ||
* 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; | ||
@@ -300,32 +299,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; | ||
} | ||
@@ -556,2 +535,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) { | ||
@@ -558,0 +547,0 @@ el = el || document; |
@@ -25,5 +25,7 @@ (function (global, factory) { | ||
* | ||
* @param {Array<?>} arr | ||
* @template T | ||
* | ||
* @return {Array<?>} | ||
* @param {T[][] | T[] | null} [arr] | ||
* | ||
* @return {T[]} | ||
*/ | ||
@@ -59,6 +61,7 @@ | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
* @return {T} return result that stopped the iteration | ||
*/ | ||
@@ -287,12 +290,8 @@ function forEach(collection, iterator) { | ||
* 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; | ||
@@ -302,32 +301,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; | ||
} | ||
@@ -558,2 +537,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) { | ||
@@ -560,0 +549,0 @@ el = el || document; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MinDom={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}const n=Object.prototype.toString,r=Object.prototype.hasOwnProperty;function o(e,t){return r.call(e,t)}function i(e,t){let r,i;if(void 0===e)return;const c=function(e){return"[object Array]"===n.call(e)}(e)?u:l;for(let n in e)if(o(e,n)&&(r=e[n],i=t(r,c(n)),!1===i))return r}function l(e){return e}function u(e){return Number(e)}const c=Object.prototype.toString;function a(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function d(e,t){return e&&"function"==typeof e.matches&&e.matches(t)}function s(e,t,n){for(var r=n?e:e.parentNode;r&&r.nodeType!==document.DOCUMENT_NODE&&r.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(d(r,t))return r;r=r.parentNode}return d(r,t)?r:null}a.prototype.add=function(e){return this.list.add(e),this},a.prototype.remove=function(e){return"[object RegExp]"==c.call(e)?this.removeMatching(e):(this.list.remove(e),this)},a.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},a.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},a.prototype.array=function(){return Array.from(this.list)},a.prototype.has=a.prototype.contains=function(e){return this.list.contains(e)};var f,p,h,y={};function g(){f=window.addEventListener?"addEventListener":"attachEvent",p=window.removeEventListener?"removeEventListener":"detachEvent",h="addEventListener"!==f?"on":""}var b=t({__proto__:null,bind:y.bind=function(e,t,n,r){return f||g(),e[f](h+t,n,r||!1),n},unbind:y.unbind=function(e,t,n,r){return p||g(),e[p](h+t,n,r||!1),n},default:y},[y]),v=["focus","blur"];var m,E={bind:function(e,t,n,r,o){return-1!==v.indexOf(n)&&(o=!0),b.bind(e,n,(function(n){var o=n.target||n.srcElement;n.delegateTarget=s(o,t,!0),n.delegateTarget&&r.call(e,n)}),o)},unbind:function(e,t,n,r){return-1!==v.indexOf(t)&&(r=!0),b.unbind(e,t,n,r)}},O=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){return(o=t.createElement("html")).innerHTML=e,o.removeChild(o.lastChild)}var o,i=Object.prototype.hasOwnProperty.call(T,r)?T[r]:T._default,l=i[0],u=i[1],c=i[2];(o=t.createElement("div")).innerHTML=u+e+c;for(;l--;)o=o.lastChild;if(o.firstChild==o.lastChild)return o.removeChild(o.firstChild);var a=t.createDocumentFragment();for(;o.firstChild;)a.appendChild(o.removeChild(o.firstChild));return a},w=!1;"undefined"!=typeof document&&((m=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',w=!m.getElementsByTagName("link").length,m=void 0);var T={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:w?[1,"X<div>","</div>"]:[0,"",""]};T.td=T.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],T.option=T.optgroup=[1,'<select multiple="multiple">',"</select>"],T.thead=T.tbody=T.colgroup=T.caption=T.tfoot=[1,"<table>","</table>"],T.polyline=T.ellipse=T.polygon=T.circle=T.text=T.line=T.path=T.rect=T.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var C=O;e.assignStyle=function(e,...t){const n=e.style;return i(t,(function(e){e&&i(e,(function(e,t){n[t]=e}))})),e},e.attr=function(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)},e.classes=function(e){return new a(e)},e.clear=function(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e},e.closest=s,e.delegate=E,e.domify=C,e.event=b,e.matches=d,e.query=function(e,t){return(t=t||document).querySelector(e)},e.queryAll=function(e,t){return(t=t||document).querySelectorAll(e)},e.remove=function(e){e.parentNode&&e.parentNode.removeChild(e)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MinDom={})}(this,(function(t){"use strict";function e(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}const n=Object.prototype.toString,r=Object.prototype.hasOwnProperty;function o(t,e){return r.call(t,e)}function i(t,e){let r,i;if(void 0===t)return;const u=function(t){return"[object Array]"===n.call(t)}(t)?c:l;for(let n in t)if(o(t,n)&&(r=t[n],i=e(r,u(n)),!1===i))return r}function l(t){return t}function c(t){return Number(t)}const u=Object.prototype.toString;function a(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}function s(t,e,n){var r=n?t:t.parentNode;return r&&"function"==typeof r.closest&&r.closest(e)||null}a.prototype.add=function(t){return this.list.add(t),this},a.prototype.remove=function(t){return"[object RegExp]"==u.call(t)?this.removeMatching(t):(this.list.remove(t),this)},a.prototype.removeMatching=function(t){const e=this.array();for(let n=0;n<e.length;n++)t.test(e[n])&&this.remove(e[n]);return this},a.prototype.toggle=function(t,e){return void 0!==e?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this},a.prototype.array=function(){return Array.from(this.list)},a.prototype.has=a.prototype.contains=function(t){return this.list.contains(t)};var d,f,p,h={};function y(){d=window.addEventListener?"addEventListener":"attachEvent",f=window.removeEventListener?"removeEventListener":"detachEvent",p="addEventListener"!==d?"on":""}var b=e({__proto__:null,bind:h.bind=function(t,e,n,r){return d||y(),t[d](p+e,n,r||!1),n},unbind:h.unbind=function(t,e,n,r){return f||y(),t[f](p+e,n,r||!1),n},default:h},[h]),g=["focus","blur"];var v,m={bind:function(t,e,n,r,o){return-1!==g.indexOf(n)&&(o=!0),b.bind(t,n,(function(n){var o=n.target||n.srcElement;n.delegateTarget=s(o,e,!0),n.delegateTarget&&r.call(t,n)}),o)},unbind:function(t,e,n,r){return-1!==g.indexOf(e)&&(r=!0),b.unbind(t,e,n,r)}},w=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){return(o=e.createElement("html")).innerHTML=t,o.removeChild(o.lastChild)}var o,i=Object.prototype.hasOwnProperty.call(O,r)?O[r]:O._default,l=i[0],c=i[1],u=i[2];(o=e.createElement("div")).innerHTML=c+t+u;for(;l--;)o=o.lastChild;if(o.firstChild==o.lastChild)return o.removeChild(o.firstChild);var a=e.createDocumentFragment();for(;o.firstChild;)a.appendChild(o.removeChild(o.firstChild));return a},E=!1;"undefined"!=typeof document&&((v=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',E=!v.getElementsByTagName("link").length,v=void 0);var O={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:E?[1,"X<div>","</div>"]:[0,"",""]};O.td=O.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],O.option=O.optgroup=[1,'<select multiple="multiple">',"</select>"],O.thead=O.tbody=O.colgroup=O.caption=O.tfoot=[1,"<table>","</table>"],O.polyline=O.ellipse=O.polygon=O.circle=O.text=O.line=O.path=O.rect=O.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var C=w;t.assignStyle=function(t,...e){const n=t.style;return i(e,(function(t){t&&i(t,(function(t,e){n[e]=t}))})),t},t.attr=function(t,e,n){return 2==arguments.length?t.getAttribute(e):null===n?t.removeAttribute(e):(t.setAttribute(e,n),t)},t.classes=function(t){return new a(t)},t.clear=function(t){return t.replaceChildren(),t},t.closest=s,t.delegate=m,t.domify=C,t.event=b,t.matches=function(t,e){return t&&"function"==typeof t.matches&&t.matches(e)||!1},t.query=function(t,e){return(e=e||document).querySelector(t)},t.queryAll=function(t,e){return(e=e||document).querySelectorAll(t)},t.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "min-dom", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "A minimal dom utility toolbelt", | ||
@@ -38,3 +38,3 @@ "main": "dist/index.js", | ||
"domify": "^1.4.1", | ||
"min-dash": "^4.0.0" | ||
"min-dash": "^4.2.1" | ||
}, | ||
@@ -45,20 +45,20 @@ "devDependencies": { | ||
"@rollup/plugin-node-resolve": "^14.1.0", | ||
"@types/chai": "^4.3.3", | ||
"@types/mocha": "^9.1.1", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.23.1", | ||
"eslint-plugin-bpmn-io": "^0.15.1", | ||
"karma": "^6.4.0", | ||
"@types/chai": "^4.3.12", | ||
"@types/mocha": "^10.0.6", | ||
"chai": "^4.4.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-bpmn-io": "^1.0.0", | ||
"karma": "^6.4.3", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-firefox-launcher": "^2.1.3", | ||
"karma-mocha": "^2.0.1", | ||
"karma-webpack": "^5.0.0", | ||
"mocha": "^10.0.0", | ||
"mocha": "^10.3.0", | ||
"npm-run-all": "^4.1.2", | ||
"puppeteer": "^17.1.3", | ||
"puppeteer": "^22.4.0", | ||
"rollup": "^2.79.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.8.3", | ||
"webpack": "^5.74.0" | ||
"typescript": "^5.3.3", | ||
"webpack": "^5.90.3" | ||
}, | ||
@@ -65,0 +65,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
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
123338
11
1480
Updatedmin-dash@^4.2.1