Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skatejs-named-slots

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skatejs-named-slots - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

22

dist/index.js

@@ -24,2 +24,17 @@ (function (global, factory) {

// Re-implemented to avoid Array.prototype.slice.call for performance reasons
function reverse(arr) {
var reversedArray = [];
for (var i = arr.length - 1; i >= 0; i--) {
reversedArray.push(arr[i]);
}
return reversedArray;
}
/**
* Execute func over all child nodes or a document fragment, or a single node
* @param node the node or document fragment
* @param func a function to execute on node or the children of node, if node is a document fragment.
* func may optionally append the node elsewhere, in the case of a document fragment
*/
function eachNodeOrFragmentNodes(node, func) {

@@ -29,4 +44,7 @@ if (node instanceof DocumentFragment) {

var chsLen = chs.length;
for (var a = 0; a < chsLen; a++) {
func(chs[a], a);
// We must iterate in reverse to handle the case where child nodes are moved elsewhere during execution
for (var a = chsLen - 1; a >= 0; a--) {
var thisNode = reverse(node.childNodes)[a];
func(thisNode, a);
}

@@ -33,0 +51,0 @@ } else {

2

dist/index.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("debounce"),require("custom-event-polyfill")):"function"==typeof define&&define.amd?define(["exports","debounce","custom-event-polyfill"],t):t(e.skatejsNamedSlots=e.skatejsNamedSlots||{},e.debounce,e.customEventPolyfill)}(this,function(e,t,n){function i(e,t){if(e)for(var n=e.childNodes,i=n.length,r=0;r<i;r++){var o=t(n[r],r,n);if("undefined"!=typeof o)return o}}function r(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,i=n.length,r=0;r<i;r++)t(n[r],r);else t(e,0)}function o(e,t){for(var n=void 0;e&&!(n=Object.getOwnPropertyDescriptor(e,t));)e=Object.getPrototypeOf(e);return n}function s(e,t){e instanceof Node&&(e=F);var n=o(e,t);if(n){var i=n.get,r=n.set,s={configurable:!0,enumerable:!0};if(i)return s.get=i,s.set=r,s;if("function"==typeof e[t])return s.value=e[t],s}var u=Object.getOwnPropertyDescriptor(e,t);if(u&&u.get)return u}function u(e){return e.textContent.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a(e){return e.text||"<!--"+e.textContent+"-->"}function d(e){return"SLOT"===e.tagName}function l(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],n=e.childNodes;if(!n||e.nodeType!==Node.ELEMENT_NODE)return t;for(var i=n.length,r=0;r<i;r++){var o=n[r];d(o)&&t.push(o),l(o,t)}return t}function h(e){return"_SHADOW_ROOT_"===e.tagName}function c(e){var t=document.createElement("div");if(q)return t.__innerHTML=e,t;for(var n=ae.parseFromString("<div>"+e+"</div>","text/html").body.firstChild;n.hasChildNodes();){var i=n.firstChild;n.removeChild(i),t.appendChild(i)}return document.importNode(t,!0)}function f(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function _(e){return this[e]}function p(e){return e.item=_,e}function v(e){return!!te.get(e)}function g(e){return v(e)?"host":d(e)?"slot":h(e)?"root":"node"}function m(e,t){for(;e&&e!==document;){if(t(e))return e;e=e.parentNode}}function N(e){return e.getAttribute&&e.getAttribute("name")||"default"}function C(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function y(e,t,n){if((3!==t.nodeType||!t.textContent||0!==t.textContent.trim().length)&&Z.indexOf(t.nodeType)!==-1){var i=e.assignedNodes(),r=0===i.length,o=i.indexOf(n);re.set(t,e),r&&X.call(e.childNodes,function(t){return e.__removeChild(t)}),o>-1?(e.__insertBefore(t,void 0!==n?n:null),i.splice(o,0,t)):(e.__appendChild(t),i.push(t)),e.____triggerSlotChangeEvent()}}function b(e){var t=e.assignedSlot;if(t){var n=t.assignedNodes(),i=n.indexOf(e);if(i>-1){var r=1===n.length;n.splice(i,1),re.set(e,null),t.__removeChild(e),r&&X.call(t.childNodes,function(e){return t.__appendChild(e)}),t.____triggerSlotChangeEvent()}}}function E(e,t){for(var n=e.childNodes,i=n.length,r=0;r<i;r++)if(n[r]===t)return r;return-1}function O(e,t,n,i){var o=E(e,n);r(t,function(t,n){i(t,n),q?ie.set(t,e):f(t,"parentNode",e),o>-1?V.splice.call(e.childNodes,o+n,0,t):V.push.call(e.childNodes,t)})}function w(e,t,n){var i=E(e,t);i>-1&&(n(t,0),q?ie.set(t,null):f(t,"parentNode",null),V.splice.call(e.childNodes,i,1))}function T(e,t,n){O(e,t,n,function(t){e.__insertBefore(t,void 0!==n?n:null)})}function M(e,t,n){O(e,t,n,function(t){var i=te.get(e),r=se.get(i),o=r[C(t)];o&&y(o,t,n)})}function x(e,t){var n=N(t);q||Array.isArray(t.childNodes)||f(t,"childNodes",G(t.childNodes)),se.get(e)[n]=t,ue.has(t)||ue.set(t,e),i(oe.get(e),function(e){e.assignedSlot||n!==C(e)||y(t,e)})}function L(e,t,n){r(t,function(t){if(d(t))x(e,t);else{var n=l(t);if(n)for(var i=n.length,r=0;r<i;r++)x(e,n[r])}}),T(e,t,n)}function S(e,t,n){var i=0===e.assignedNodes().length;O(e,t,n,function(t){i&&e.__insertBefore(t,void 0!==n?n:null)})}function j(e,t){var n=0===e.assignedNodes().length;w(e,t,function(){n&&e.__removeChild(t)})}function k(e,t){w(e,t,function(){e.__removeChild(t)})}function P(e,t){w(e,t,function(){b(t)})}function A(e,t){t.assignedNodes().forEach(b),delete se.get(e)[N(t)],ue.delete(t)}function W(e,t){w(e,t,function(){if(d(t))A(e,t);else{var n=l(t);if(n)for(var i=0;i<n.length;i++)A(e,n[i])}e.__removeChild(t)})}function D(e){if(h(e))return e;if(e.parentNode)return D(e.parentNode)}function H(e,t,n){var i=g(e),r=t.parentNode,o=D(e);return q||Array.isArray(e.childNodes)||f(e,"childNodes",G(e.childNodes)),o&&"slot"===g(t)&&x(o,t),r&&"host"===g(r)&&(q?ie.set(t,null):f(t,"parentNode",null)),"node"===i?q?(ie.set(t,e),e.__insertBefore(t,void 0!==n?n:null)):T(e,t,n):"slot"===i?S(e,t,n):"host"===i?M(e,t,n):"root"===i?L(e,t,n):void 0}function B(e){if(q&&"slot"===g(e)&&e.__childNodes.length!==e.childNodes.length){for(;e.hasChildNodes();)e.removeChild(e.firstChild);X.call(e.__childNodes,function(t){return e.appendChild(t)})}}t="default"in t?t.default:t;var F=document.createElement("div"),R=s(Element.prototype,"innerHTML"),q=!!R,G=function(e){return Array.prototype.slice.call(e)},I="0.0.1";"undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var i=t[this.name];return i&&i[0]===t?i[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},delete:function(e){var t=e[this.name];return!(!t||t[0]!==e)&&(t[0]=t[1]=void 0,!0)},has:function(e){var t=e[this.name];return!!t&&t[0]===e}},window.WeakMap=n}();var V=Array.prototype,X=V.forEach,Y="_shadow_root_",z=["childNodes","parentNode"],J=["textContent"],K=["assignedSlot"],Q=["textContent"],U=[],Z=[Node.ELEMENT_NODE,Node.TEXT_NODE],$=new WeakMap,ee=new WeakMap,te=new WeakMap,ne=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,se=new WeakMap,ue=new WeakMap,ae=new DOMParser,de={____assignedNodes:{get:function(){return this.______assignedNodes||(this.______assignedNodes=[])}},____isInFallbackMode:{get:function(){return 0===this.assignedNodes().length}},____slotChangeListeners:{get:function(){return"undefined"==typeof this.______slotChangeListeners&&(this.______slotChangeListeners=0),this.______slotChangeListeners},set:function(e){this.______slotChangeListeners=e}},____triggerSlotChangeEvent:{value:t(function(){this.____slotChangeListeners&&this.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1}))})},addEventListener:{value:function(e,t,n){return"slotchange"===e&&d(this)&&this.____slotChangeListeners++,this.__addEventListener(e,t,n)}},appendChild:{value:function(e){return H(this,e),e}},assignedSlot:{get:function(){var e=re.get(this);if(!e)return null;var t=ue.get(e),n=oe.get(t),i=ee.get(n);return"open"===i?e:null}},attachShadow:{value:function(e){var t=this,n=e&&e.mode;if("closed"!==n&&"open"!==n)throw new Error('You must specify { mode } as "open" or "closed" to attachShadow().');var i=te.get(this);if(i)return i;var r=p([].slice.call(this.childNodes)),o=document.createElement(e.polyfillShadowRootTagName||Y);return ee.set(this,n),te.set(this,o),oe.set(o,this),se.set(o,{}),q?ne.set(this,r):f(this,"childNodes",r),r.forEach(function(e){t.__removeChild(e),q?ie.set(e,t):f(e,"parentNode",t)}),this.__appendChild(o)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(q&&"node"===g(this))return this.__childNodes;var e=ne.get(this);return e||ne.set(this,e=p([])),e}},children:{get:function(){var e=[];return i(this,function(t){1===t.nodeType&&e.push(t)}),p(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},assignedNodes:{value:function(){if(d(this)){var e=$.get(this);return e||$.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="",t=function(e){return e.outerHTML},n={1:t,3:u,8:a};return i(this,function(i){var r=n[i.nodeType]||t;e+=r(i)}),e},set:function(e){for(var t=c(e);this.hasChildNodes();)this.removeChild(this.firstChild);var n=l(t);for(X.call(n,function(e){return B(e)});t.hasChildNodes();){var i=t.firstChild;t.removeChild(i),this.appendChild(i)}}},insertBefore:{value:function(e,t){return H(this,e,t),e}},lastChild:{get:function(){var e=this.childNodes;return e[e.length-1]||null}},lastElementChild:{get:function(){var e=this.children;return e[e.length-1]||null}},name:{get:function(){return this.getAttribute("name")},set:function(e){return this.setAttribute("name",e)}},nextSibling:{get:function(){var e=this;return i(this.parentNode,function(t,n,i){if(e===t)return i[n+1]||null})}},nextElementSibling:{get:function(){var e=this,t=void 0;return i(this.parentNode,function(n){return t&&1===n.nodeType?n:void(e===n&&(t=!0))})}},outerHTML:{get:function(){var e=this.tagName.toLowerCase(),t=Array.prototype.slice.call(this.attributes).map(function(e){return" "+e.name+(e.value?'="'+e.value+'"':"")}).join("");return"<"+e+t+">"+this.innerHTML+"</"+e+">"},set:function(e){if(this.parentNode){var t=c(e);this.parentNode.replaceChild(t.firstChild,this)}else{if(!q)throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");this.__outerHTML=e}}},parentElement:{get:function(){return m(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return ie.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return i(this.parentNode,function(t,n,i){if(e===t)return i[n-1]||null})}},previousElementSibling:{get:function(){var e=this,t=void 0;return i(this.parentNode,function(n){return t&&e===n?t:void(1===n.nodeType&&(t=n))})}},removeChild:{value:function(e){var t=g(this);switch(t){case"node":if(q)return ie.set(e,null),this.__removeChild(e);k(this,e);break;case"slot":j(this,e);break;case"host":P(this,e);break;case"root":W(this,e)}return e}},removeEventListener:{value:function(e,t,n){return"slotchange"===e&&this.____slotChangeListeners&&d(this)&&this.____slotChangeListeners--,this.__removeEventListener(e,t,n)}},replaceChild:{value:function(e,t){return this.insertBefore(e,t),this.removeChild(t)}},shadowRoot:{get:function(){return"open"===ee.get(this)?te.get(this):null}},textContent:{get:function(){var e="";return i(this,function(t){t.nodeType!==Node.COMMENT_NODE&&(e+=t.textContent)}),e},set:function(e){for(;this.hasChildNodes();)this.removeChild(this.firstChild);e&&this.appendChild(document.createTextNode(e))}}};"attachShadow"in document.createElement("div")||!function(){var e=Comment.prototype,t=HTMLElement.prototype,n=SVGElement.prototype,i=Text.prototype,r=document.createTextNode(""),o=document.createComment("");Object.keys(de).forEach(function(u){var a=de[u];if(a.configurable=!0,a.hasOwnProperty("value")&&(a.writable=!0),q||z.indexOf(u)===-1){var d=s(t,u),l=s(i,u),h=s(e,u),c=u in r&&J.indexOf(u)===-1||~K.indexOf(u),f=u in o&&Q.indexOf(u)===-1||~U.indexOf(u),_="__"+u;Object.defineProperty(t,u,a),Object.defineProperty(n,u,a),d&&(Object.defineProperty(t,_,d),Object.defineProperty(n,_,d)),c&&Object.defineProperty(i,u,a),c&&l&&Object.defineProperty(i,_,l),f&&Object.defineProperty(e,u,a),f&&h&&Object.defineProperty(e,_,h)}})}(),e.default=I,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("debounce"),require("custom-event-polyfill")):"function"==typeof define&&define.amd?define(["exports","debounce","custom-event-polyfill"],t):t(e.skatejsNamedSlots=e.skatejsNamedSlots||{},e.debounce,e.customEventPolyfill)}(this,function(e,t,n){function i(e,t){if(e)for(var n=e.childNodes,i=n.length,r=0;r<i;r++){var o=t(n[r],r,n);if("undefined"!=typeof o)return o}}function r(e){for(var t=[],n=e.length-1;n>=0;n--)t.push(e[n]);return t}function o(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,i=n.length,o=i-1;o>=0;o--){var s=r(e.childNodes)[o];t(s,o)}else t(e,0)}function s(e,t){for(var n=void 0;e&&!(n=Object.getOwnPropertyDescriptor(e,t));)e=Object.getPrototypeOf(e);return n}function u(e,t){e instanceof Node&&(e=R);var n=s(e,t);if(n){var i=n.get,r=n.set,o={configurable:!0,enumerable:!0};if(i)return o.get=i,o.set=r,o;if("function"==typeof e[t])return o.value=e[t],o}var u=Object.getOwnPropertyDescriptor(e,t);if(u&&u.get)return u}function a(e){return e.textContent.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function d(e){return e.text||"<!--"+e.textContent+"-->"}function l(e){return"SLOT"===e.tagName}function h(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],n=e.childNodes;if(!n||e.nodeType!==Node.ELEMENT_NODE)return t;for(var i=n.length,r=0;r<i;r++){var o=n[r];l(o)&&t.push(o),h(o,t)}return t}function c(e){return"_SHADOW_ROOT_"===e.tagName}function f(e){var t=document.createElement("div");if(G)return t.__innerHTML=e,t;for(var n=de.parseFromString("<div>"+e+"</div>","text/html").body.firstChild;n.hasChildNodes();){var i=n.firstChild;n.removeChild(i),t.appendChild(i)}return document.importNode(t,!0)}function _(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function p(e){return this[e]}function v(e){return e.item=p,e}function g(e){return!!ne.get(e)}function N(e){return g(e)?"host":l(e)?"slot":c(e)?"root":"node"}function m(e,t){for(;e&&e!==document;){if(t(e))return e;e=e.parentNode}}function C(e){return e.getAttribute&&e.getAttribute("name")||"default"}function y(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function b(e,t,n){if((3!==t.nodeType||!t.textContent||0!==t.textContent.trim().length)&&$.indexOf(t.nodeType)!==-1){var i=e.assignedNodes(),r=0===i.length,o=i.indexOf(n);oe.set(t,e),r&&Y.call(e.childNodes,function(t){return e.__removeChild(t)}),o>-1?(e.__insertBefore(t,void 0!==n?n:null),i.splice(o,0,t)):(e.__appendChild(t),i.push(t)),e.____triggerSlotChangeEvent()}}function E(e){var t=e.assignedSlot;if(t){var n=t.assignedNodes(),i=n.indexOf(e);if(i>-1){var r=1===n.length;n.splice(i,1),oe.set(e,null),t.__removeChild(e),r&&Y.call(t.childNodes,function(e){return t.__appendChild(e)}),t.____triggerSlotChangeEvent()}}}function O(e,t){for(var n=e.childNodes,i=n.length,r=0;r<i;r++)if(n[r]===t)return r;return-1}function w(e,t,n,i){var r=O(e,n);o(t,function(t,n){i(t,n),G?re.set(t,e):_(t,"parentNode",e),r>-1?X.splice.call(e.childNodes,r+n,0,t):X.push.call(e.childNodes,t)})}function T(e,t,n){var i=O(e,t);i>-1&&(n(t,0),G?re.set(t,null):_(t,"parentNode",null),X.splice.call(e.childNodes,i,1))}function M(e,t,n){w(e,t,n,function(t){e.__insertBefore(t,void 0!==n?n:null)})}function x(e,t,n){w(e,t,n,function(t){var i=ne.get(e),r=ue.get(i),o=r[y(t)];o&&b(o,t,n)})}function L(e,t){var n=C(t);G||Array.isArray(t.childNodes)||_(t,"childNodes",I(t.childNodes)),ue.get(e)[n]=t,ae.has(t)||ae.set(t,e),i(se.get(e),function(e){e.assignedSlot||n!==y(e)||b(t,e)})}function S(e,t,n){o(t,function(t){if(l(t))L(e,t);else{var n=h(t);if(n)for(var i=n.length,r=0;r<i;r++)L(e,n[r])}}),M(e,t,n)}function j(e,t,n){var i=0===e.assignedNodes().length;w(e,t,n,function(t){i&&e.__insertBefore(t,void 0!==n?n:null)})}function k(e,t){var n=0===e.assignedNodes().length;T(e,t,function(){n&&e.__removeChild(t)})}function P(e,t){T(e,t,function(){e.__removeChild(t)})}function A(e,t){T(e,t,function(){E(t)})}function W(e,t){t.assignedNodes().forEach(E),delete ue.get(e)[C(t)],ae.delete(t)}function D(e,t){T(e,t,function(){if(l(t))W(e,t);else{var n=h(t);if(n)for(var i=0;i<n.length;i++)W(e,n[i])}e.__removeChild(t)})}function H(e){if(c(e))return e;if(e.parentNode)return H(e.parentNode)}function B(e,t,n){var i=N(e),r=t.parentNode,o=H(e);return G||Array.isArray(e.childNodes)||_(e,"childNodes",I(e.childNodes)),o&&"slot"===N(t)&&L(o,t),r&&"host"===N(r)&&(G?re.set(t,null):_(t,"parentNode",null)),"node"===i?G?(re.set(t,e),e.__insertBefore(t,void 0!==n?n:null)):M(e,t,n):"slot"===i?j(e,t,n):"host"===i?x(e,t,n):"root"===i?S(e,t,n):void 0}function F(e){if(G&&"slot"===N(e)&&e.__childNodes.length!==e.childNodes.length){for(;e.hasChildNodes();)e.removeChild(e.firstChild);Y.call(e.__childNodes,function(t){return e.appendChild(t)})}}t="default"in t?t.default:t;var R=document.createElement("div"),q=u(Element.prototype,"innerHTML"),G=!!q,I=function(e){return Array.prototype.slice.call(e)},V="0.0.1";"undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var i=t[this.name];return i&&i[0]===t?i[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},delete:function(e){var t=e[this.name];return!(!t||t[0]!==e)&&(t[0]=t[1]=void 0,!0)},has:function(e){var t=e[this.name];return!!t&&t[0]===e}},window.WeakMap=n}();var X=Array.prototype,Y=X.forEach,z="_shadow_root_",J=["childNodes","parentNode"],K=["textContent"],Q=["assignedSlot"],U=["textContent"],Z=[],$=[Node.ELEMENT_NODE,Node.TEXT_NODE],ee=new WeakMap,te=new WeakMap,ne=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,se=new WeakMap,ue=new WeakMap,ae=new WeakMap,de=new DOMParser,le={____assignedNodes:{get:function(){return this.______assignedNodes||(this.______assignedNodes=[])}},____isInFallbackMode:{get:function(){return 0===this.assignedNodes().length}},____slotChangeListeners:{get:function(){return"undefined"==typeof this.______slotChangeListeners&&(this.______slotChangeListeners=0),this.______slotChangeListeners},set:function(e){this.______slotChangeListeners=e}},____triggerSlotChangeEvent:{value:t(function(){this.____slotChangeListeners&&this.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1}))})},addEventListener:{value:function(e,t,n){return"slotchange"===e&&l(this)&&this.____slotChangeListeners++,this.__addEventListener(e,t,n)}},appendChild:{value:function(e){return B(this,e),e}},assignedSlot:{get:function(){var e=oe.get(this);if(!e)return null;var t=ae.get(e),n=se.get(t),i=te.get(n);return"open"===i?e:null}},attachShadow:{value:function(e){var t=this,n=e&&e.mode;if("closed"!==n&&"open"!==n)throw new Error('You must specify { mode } as "open" or "closed" to attachShadow().');var i=ne.get(this);if(i)return i;var r=v([].slice.call(this.childNodes)),o=document.createElement(e.polyfillShadowRootTagName||z);return te.set(this,n),ne.set(this,o),se.set(o,this),ue.set(o,{}),G?ie.set(this,r):_(this,"childNodes",r),r.forEach(function(e){t.__removeChild(e),G?re.set(e,t):_(e,"parentNode",t)}),this.__appendChild(o)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(G&&"node"===N(this))return this.__childNodes;var e=ie.get(this);return e||ie.set(this,e=v([])),e}},children:{get:function(){var e=[];return i(this,function(t){1===t.nodeType&&e.push(t)}),v(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},assignedNodes:{value:function(){if(l(this)){var e=ee.get(this);return e||ee.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="",t=function(e){return e.outerHTML},n={1:t,3:a,8:d};return i(this,function(i){var r=n[i.nodeType]||t;e+=r(i)}),e},set:function(e){for(var t=f(e);this.hasChildNodes();)this.removeChild(this.firstChild);var n=h(t);for(Y.call(n,function(e){return F(e)});t.hasChildNodes();){var i=t.firstChild;t.removeChild(i),this.appendChild(i)}}},insertBefore:{value:function(e,t){return B(this,e,t),e}},lastChild:{get:function(){var e=this.childNodes;return e[e.length-1]||null}},lastElementChild:{get:function(){var e=this.children;return e[e.length-1]||null}},name:{get:function(){return this.getAttribute("name")},set:function(e){return this.setAttribute("name",e)}},nextSibling:{get:function(){var e=this;return i(this.parentNode,function(t,n,i){if(e===t)return i[n+1]||null})}},nextElementSibling:{get:function(){var e=this,t=void 0;return i(this.parentNode,function(n){return t&&1===n.nodeType?n:void(e===n&&(t=!0))})}},outerHTML:{get:function(){var e=this.tagName.toLowerCase(),t=Array.prototype.slice.call(this.attributes).map(function(e){return" "+e.name+(e.value?'="'+e.value+'"':"")}).join("");return"<"+e+t+">"+this.innerHTML+"</"+e+">"},set:function(e){if(this.parentNode){var t=f(e);this.parentNode.replaceChild(t.firstChild,this)}else{if(!G)throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");this.__outerHTML=e}}},parentElement:{get:function(){return m(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return re.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return i(this.parentNode,function(t,n,i){if(e===t)return i[n-1]||null})}},previousElementSibling:{get:function(){var e=this,t=void 0;return i(this.parentNode,function(n){return t&&e===n?t:void(1===n.nodeType&&(t=n))})}},removeChild:{value:function(e){var t=N(this);switch(t){case"node":if(G)return re.set(e,null),this.__removeChild(e);P(this,e);break;case"slot":k(this,e);break;case"host":A(this,e);break;case"root":D(this,e)}return e}},removeEventListener:{value:function(e,t,n){return"slotchange"===e&&this.____slotChangeListeners&&l(this)&&this.____slotChangeListeners--,this.__removeEventListener(e,t,n)}},replaceChild:{value:function(e,t){return this.insertBefore(e,t),this.removeChild(t)}},shadowRoot:{get:function(){return"open"===te.get(this)?ne.get(this):null}},textContent:{get:function(){var e="";return i(this,function(t){t.nodeType!==Node.COMMENT_NODE&&(e+=t.textContent)}),e},set:function(e){for(;this.hasChildNodes();)this.removeChild(this.firstChild);e&&this.appendChild(document.createTextNode(e))}}};"attachShadow"in document.createElement("div")||!function(){var e=Comment.prototype,t=HTMLElement.prototype,n=SVGElement.prototype,i=Text.prototype,r=document.createTextNode(""),o=document.createComment("");Object.keys(le).forEach(function(s){var a=le[s];if(a.configurable=!0,a.hasOwnProperty("value")&&(a.writable=!0),G||J.indexOf(s)===-1){var d=u(t,s),l=u(i,s),h=u(e,s),c=s in r&&K.indexOf(s)===-1||~Q.indexOf(s),f=s in o&&U.indexOf(s)===-1||~Z.indexOf(s),_="__"+s;Object.defineProperty(t,s,a),Object.defineProperty(n,s,a),d&&(Object.defineProperty(t,_,d),Object.defineProperty(n,_,d)),c&&Object.defineProperty(i,s,a),c&&l&&Object.defineProperty(i,_,l),f&&Object.defineProperty(e,s,a),f&&h&&Object.defineProperty(e,_,h)}})}(),e.default=V,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=index.min.js.map

@@ -51,3 +51,3 @@ {

},
"version": "0.3.0"
"version": "0.3.1"
}

@@ -16,2 +16,17 @@ export function eachChildNode(node, func) {

// Re-implemented to avoid Array.prototype.slice.call for performance reasons
function reverse(arr) {
let reversedArray = [];
for (let i = arr.length - 1; i >= 0; i--) {
reversedArray.push(arr[i]);
}
return reversedArray;
}
/**
* Execute func over all child nodes or a document fragment, or a single node
* @param node the node or document fragment
* @param func a function to execute on node or the children of node, if node is a document fragment.
* func may optionally append the node elsewhere, in the case of a document fragment
*/
export function eachNodeOrFragmentNodes(node, func) {

@@ -21,4 +36,7 @@ if (node instanceof DocumentFragment) {

const chsLen = chs.length;
for (let a = 0; a < chsLen; a++) {
func(chs[a], a);
// We must iterate in reverse to handle the case where child nodes are moved elsewhere during execution
for (let a = chsLen - 1; a >= 0; a--) {
const thisNode = reverse(node.childNodes)[a];
func(thisNode, a);
}

@@ -25,0 +43,0 @@ } else {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc