-
Notifications
You must be signed in to change notification settings - Fork 45
/
NodeList.min.js
1 lines (1 loc) · 3.57 KB
/
NodeList.min.js
1
!function(){function f(a,b){for(var h,i,j,d=[],e=0,f=a.length;f>e;e++)if(j=a[e],j instanceof Node||null==j)d.indexOf(j)<0&&d.push(j);else{if(!(j instanceof window.NodeList||j instanceof g||j instanceof HTMLCollection||j instanceof Array))return a.get=c.get,a.set=c.set,a.call=c.call,a.owner=b,a;for(h=0,i=j.length;i>h;h++)d.push(j[h])}return new g([d,b])}function g(a){var c,b=0,d=a;"string"==typeof a[0]?d=(a[1]||document).querySelectorAll(a[0]):0 in a&&!(a[0]instanceof Node)&&"length"in a[0]&&(d=a[0],a[1]&&(this.owner=a[1]));for(c=this.length=d.length;c>b;b++)this[b]=d[b]}function h(a){d[a]instanceof Function?c[a]=function(){for(var g,b=[],c=!0,d=0,e=this.length;e>d;d++)g=this[d],g&&g[a]instanceof Function?(g=g[a].apply(g,arguments),b.push(g),c&&void 0!==g&&(c=!1)):b.push(void 0);return c?this:f(b,this)}:Object.defineProperty(c,a,{get:function(){for(var e,b=[],c=0,d=this.length;d>c;c++)e=this[c],null!=e&&(e=e[a]),b.push(e);return f(b,this)},set:function(b){for(var e,c=0,d=this.length;d>c;c++)e=this[c],e&&a in e&&(e[a]=b)}})}var c,d,e,a=Array.prototype,b=new Error("Passed arguments must be of Node");c=g.prototype={includes:a.includes||function(a,b){return this.indexOf(a,b)>-1},forEach:function(){return a.forEach.apply(this,arguments),this},push:function k(){for(var e,k=a.push.bind(this),c=0,d=arguments.length;d>c;c++){if(e=arguments[c],!(e instanceof Node))throw b;this.indexOf(e)<0&&k(e)}return this},pop:function l(b){"number"!=typeof b&&(b=1);var d,c=[],l=a.pop.bind(this);for(d=0;b>d;d++)c.push(l());return new g([c,this])},unshift:function m(){for(var e,m=a.unshift.bind(this),c=0,d=arguments.length;d>c;c++){if(e=arguments[c],!(e instanceof Node))throw b;this.indexOf(e)<0&&m(e)}return this},shift:function n(b){"number"!=typeof b&&(b=1);var d,c=[],n=a.shift.bind(this);for(d=0;b>d;d++)c.push(n());return new g([c,this])},splice:function(){for(var c=2,d=arguments.length;d>c;c++)if(!(arguments[c]instanceof Node))throw b;return new g([a.splice.apply(this,arguments),this])},slice:function(){return new g([a.slice.apply(this,arguments),this])},filter:function(){return new g([a.filter.apply(this,arguments),this])},map:function(){return f(a.map.apply(this,arguments),this)},concat:function(){function f(a){for(var c=0,d=a.length;d>c;c++)a[c]instanceof Node?b.indexOf(a[c])<0&&b.push(a[c]):a[c]&&f(a[c])}for(var e,b=a.slice.call(this),c=0,d=arguments.length;d>c;c++)if(e=arguments[c],e instanceof Node)b.indexOf(e)<0&&b.push(e);else{if(!(e instanceof window.NodeList||e instanceof g||e instanceof HTMLCollection||e instanceof Array))throw Error("Concat arguments must be of a Node, NodeList, HTMLCollection, or Array of (Node, NodeList, HTMLCollection, Array)");f(e)}return new g([b,this])},get:function(a){for(var e,b=[],c=0,d=this.length;d>c;c++)e=this[c],null!=e&&(e=e[a]),b.push(e);return f(b,this)},set:function(a,b){var e,f,c=0,d=this.length;if(a.constructor===Object){for(;d>c;c++)if(e=this[c])for(f in a)f in e&&(e[f]=a[f])}else for(;d>c;c++)e=this[c],e&&a in e&&(e[a]=b);return this},call:function(){for(var h,b=[],c=a.shift.call(arguments),d=!0,e=0,g=this.length;g>e;e++)h=this[e],h&&h[c]instanceof Function?(h=h[c].apply(h,arguments),b.push(h),d&&void 0!==h&&(d=!1)):b.push(void 0);return d?this:f(b,this)},item:function(a){return new g([[this[a]],this])},get asArray(){return a.slice.call(this)}},Object.getOwnPropertyNames(a).forEach(function(b){"join"!==b&&"copyWithin"!==b&&"fill"!==b&&void 0===c[b]&&(c[b]=a[b])}),window.Symbol&&Symbol.iterator&&(c[Symbol.iterator]=c.values=a[Symbol.iterator]),d=document.createElement("div");for(e in d)h(e);d=e=null,window.$$=function(){return new g(arguments)},window.$$.NL=c}();