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