Socket
Socket
Sign inDemoInstall

skatejs-named-slots

Package Overview
Dependencies
Maintainers
2
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.1.4 to 0.1.5

29

dist/index.js

@@ -283,2 +283,21 @@ (function (global, factory) {

// Don't slot nodes that have content but are only whitespace. This is an
// anomaly that I don't think the spec deals with.
//
// The problem is:
//
// - If you insert HTML with indentation into the page, there will be
// whitespace and if that's inserted it messes with fallback content
// calculation where there is formatting, but no meaningful content, so in
// theory it should fallback. Since you can attach a shadow root after we
// mean to insert an empty text node and have it "count", we can't really
// discard nodes that are considered formatting at the time of attachment.
// - You can insert a text node and modify its text content later.
// Incremental DOM seems to do this. Every way I look at it, it seems
// problematic that we should have to screen for content, but I don't seems
// much of a way around it at the moment.
if (node.nodeType === 3 && node.textContent && node.textContent.trim().length === 0) {
return;
}
nodeToSlotMap.set(node, slot);

@@ -416,5 +435,7 @@

var slotNodes = node.querySelectorAll && node.querySelectorAll('slot');
var slotNodesLen = slotNodes.length;
for (var a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
if (slotNodes) {
var slotNodesLen = slotNodes.length;
for (var a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
}
}

@@ -889,3 +910,3 @@ }

}
version.version = '0.1.4';
version.version = '0.1.5';

@@ -892,0 +913,0 @@ return version;

2

dist/index.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.skatejsNamedSlots=t()}(this,function(){function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t){if(e)for(var n=e.childNodes,i=n.length,r=0;i>r;r++){var o=t(n[r],r,n);if("undefined"!=typeof o)return o}}function n(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,i=n.length,r=0;i>r;r++)t(n[r],r);else t(e,0)}function i(e){var t=e.nodeType;if(1===t){for(var n=document.createElement(e.tagName),r=0;r<e.attributes.length;r++){var o=e.attributes[r];n.setAttribute(o.name,o.value)}for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes[r];n.appendChild(i(s))}return n}return e}function r(e){for(var t=document.createElement("div"),n=V.parseFromString(e,"text/xml");n.hasChildNodes();){var r=n.firstChild;n.removeChild(r),t.appendChild(i(r))}return t}function o(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function s(e){return this[e]}function u(e){return e.item=s,e}function l(e){return a(e)?"host":d(e)?"slot":h(e)?"root":"node"}function a(e){return!!U.get(e)}function d(e){return"SLOT"===e.tagName}function h(e){return e.tagName===q}function c(e,t){for(;e&&e!==document;){if(t(e))return e;e=e.parentNode}}function f(e){return e.getAttribute&&e.getAttribute("name")||"default"}function _(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function g(e,t,n){var i=e.getAssignedNodes(),r=i.indexOf(n);G.set(t,e),i.length||(Q.set(e,!1),[].slice.call(e.childNodes).forEach(function(t){return e.__removeChild(t)}));var o=!Q.get(e);r>-1?(o&&e.__insertBefore(t,n),i.splice(r,0,t)):(o&&e.__appendChild(t),i.push(t)),e.____triggerSlotChangeEvent()}function v(e){var n=e.assignedSlot;if(n){var i=n.getAssignedNodes(),r=i.indexOf(e);if(r>-1){i.splice(r,1),G.set(e,null);var o=!Q.get(n);o&&n.__removeChild(e),i.length||(Q.set(n,!0),t(n,function(e){n.__appendChild(e)})),n.____triggerSlotChangeEvent()}}}function p(e,t){for(var n=e.childNodes,i=n.length,r=0;i>r;r++)if(n[r]===t)return r;return-1}function m(e,t,i,r){var s=p(e,i);n(t,function(t,n){r(t,n),A?Y.set(t,e):o(t,"parentNode",e),s>-1?e.childNodes.splice(s+n,0,t):e.childNodes.push(t)})}function N(e,t,n){var i=p(e,t);i>-1&&(n(t,0),A?Y.set(t,null):o(t,"parentNode",null),e.childNodes.splice(i,1))}function C(e,t,n){m(e,t,n,function(t){e.__insertBefore(t,n)})}function y(e,t,n){m(e,t,n,function(t){var i=U.get(e),r=K.get(i),o=r[_(t)];o&&g(o,t,n)})}function w(e,t,i){n(t,function(t){if(d(t))b(e,t);else for(var n=t.querySelectorAll&&t.querySelectorAll("slot"),i=n.length,r=0;i>r;r++)b(e,n[r])}),C(e,t,i)}function b(e,n){var i=f(n);Q.set(n,!0),K.get(e)[i]=n,t(J.get(e),function(e){e.assignedSlot||i!==_(e)||g(n,e)})}function E(e,t){N(e,t,function(){e.__removeChild(t)})}function S(e,t){N(e,t,function(){v(t)})}function L(e,t){N(e,t,function(){if(d(t))x(e,t);else for(var n=t.querySelectorAll&&t.querySelectorAll("slot"),i=0;i<n.length;i++)x(e,n[i])})}function x(e,t){t.getAssignedNodes().forEach(v),delete K.get(e)[f(t)]}function T(e,t,n){var i=l(e),r=t.parentNode;return A||e.childNodes.push||o(e,"childNodes",[]),r&&"host"===l(r)&&(A?Y.set(t,null):o(t,"parentNode",null)),"node"===i?A?e.__insertBefore(t,n):C(e,t,n):"slot"===i?C(e,t,n):"host"===i?y(e,t,n):"root"===i?w(e,t,n):void 0}function j(e){for(var t=0;t<R.length;t++){var n=window[R[t]];if(n){var i=n.prototype;if(i.hasOwnProperty(e))return Object.getOwnPropertyDescriptor(i,e)}}}var A=!!Object.getOwnPropertyDescriptor(window.Node.prototype,"parentNode").get,O=e(function(e){function t(){return(new Date).getTime()}e.exports=Date.now||t}),k=O&&"object"==typeof O&&"default"in O?O["default"]:O,M=e(function(e){var t=k;e.exports=function(e,n,i){function r(){var d=t()-l;n>d&&d>0?o=setTimeout(r,n-d):(o=null,i||(a=e.apply(u,s),o||(u=s=null)))}var o,s,u,l,a;return null==n&&(n=100),function(){u=this,s=arguments,l=t();var d=i&&!o;return o||(o=setTimeout(r,n)),d&&(a=e.apply(u,s),u=s=null),a}}}),P=M&&"object"==typeof M&&"default"in M?M["default"]:M,D="0.0.1",B=window.WeakMap||function(){function e(){this.key="____weak_map_"+t++}var t=0;return e.prototype={"delete":function(e){e&&delete e[this.key]},get:function(e){return e?e[this.key]:null},has:function(e){return e?"undefined"!=typeof e[this.key]:!1},set:function(e,t){if(e){var n=this.key;"undefined"==typeof e[n]?Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value:t}):e[n]=t}}},e}(),H="_shadow_root_",q=H.toUpperCase(),F=["childNodes","parentNode"],R=["Node","Element","EventTarget"],z=new B,I=new B,U=new B,W=new B,Y=new B,G=new B,J=new B,K=new B,Q=new B,V=new DOMParser,X={____assignedNodes:{get:function(){return this.______assignedNodes||(this.______assignedNodes=[])}},____isInFallbackMode:{get:function(){return Q.get(this)}},____slotChangeListeners:{get:function(){return"undefined"==typeof this.______slotChangeListeners&&(this.______slotChangeListeners=0),this.______slotChangeListeners},set:function(e){this.______slotChangeListeners=e}},____triggerSlotChangeEvent:{value:P(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 T(this,e)}},assignedSlot:{get:function(){return G.get(this)||null}},attachShadow:{value:function(e){var n=this,i=e&&e.mode;if("closed"!==i&&"open"!==i)throw new Error('You must specify { mode } as "open" or "closed" to attachShadow().');var r=U.get(this);if(r)return r;var s=u([].slice.call(this.childNodes)),l=document.createElement(e.polyfillShadowRootTagName||H);return I.set(this,i),U.set(this,l),J.set(l,this),K.set(l,{}),A?W.set(this,s):o(this,"childNodes",s),t(this,function(e){return n.__removeChild(e)}),this.__appendChild(l)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(A&&"node"===l(this))return this.__childNodes;var e=W.get(this);return e||W.set(this,e=u([])),e}},children:{get:function(){var e=[];return t(this,function(t){1===t.nodeType&&e.push(t)}),u(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},getAssignedNodes:{value:function(){if(d(this)){var e=z.get(this);return e||z.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="";return t(this,function(t){e+=1===t.nodeType?t.outerHTML:t.textContent}),e},set:function(e){for(var t=r(e);this.hasChildNodes();)this.removeChild(this.firstChild);for(;t.hasChildNodes();){var n=t.firstChild;t.removeChild(n),this.appendChild(n)}}},insertBefore:{value:function(e,t){return T(this,e,t)}},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 t(this.parentNode,function(t,n,i){return e===t?i[n+1]||null:void 0})}},nextElementSibling:{get:function(){var e=this,n=void 0;return t(this.parentNode,function(t){return n&&1===t.nodeType?t:void(e===t&&(n=!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+">"}},parentElement:{get:function(){return c(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return Y.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return t(this.parentNode,function(t,n,i){return e===t?i[n-1]||null:void 0})}},previousElementSibling:{get:function(){var e=this,n=void 0;return t(this.parentNode,function(t){return n&&e===t?n:void(1===t.nodeType&&(n=t))})}},removeChild:{value:function(e){var t=l(this);return"node"===t?A?this.__removeChild(e):E(this,e):"slot"===t?E(this,e):"host"===t?S(this,e):"root"===t?L(this,e):void 0}},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"===I.get(this)?U.get(this):null}},textContent:{get:function(){var e="";return t(this,function(t){e+=t.textContent}),e},set:function(e){for(;this.hasChildNodes();)this.removeChild(this.firstChild);this.appendChild(document.createTextNode(e))}}};"attachShadow"in document.createElement("div")||!function(){var e=HTMLElement.prototype;Object.keys(X).forEach(function(t){var n=X[t];if(n.configurable=!0,A||-1===F.indexOf(t)){var i=j(t);Object.defineProperty(e,t,n),i&&i.configurable&&Object.defineProperty(e,"__"+t,i)}})}();var Z=Object.freeze({"default":D}),$=window.skatejsNamedSlots;D.noConflict=function(){return window.skatejsNamedSlots=$,this},window.skatejsNamedSlots=D;for(var ee in Z)D[ee]=Z[ee];return D.version="0.1.4",D});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.skatejsNamedSlots=t()}(this,function(){function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t){if(e)for(var n=e.childNodes,i=n.length,r=0;i>r;r++){var o=t(n[r],r,n);if("undefined"!=typeof o)return o}}function n(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,i=n.length,r=0;i>r;r++)t(n[r],r);else t(e,0)}function i(e){var t=e.nodeType;if(1===t){for(var n=document.createElement(e.tagName),r=0;r<e.attributes.length;r++){var o=e.attributes[r];n.setAttribute(o.name,o.value)}for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes[r];n.appendChild(i(s))}return n}return e}function r(e){for(var t=document.createElement("div"),n=V.parseFromString(e,"text/xml");n.hasChildNodes();){var r=n.firstChild;n.removeChild(r),t.appendChild(i(r))}return t}function o(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function s(e){return this[e]}function u(e){return e.item=s,e}function l(e){return a(e)?"host":d(e)?"slot":h(e)?"root":"node"}function a(e){return!!U.get(e)}function d(e){return"SLOT"===e.tagName}function h(e){return e.tagName===q}function f(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 _(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function g(e,t,n){var i=e.getAssignedNodes(),r=i.indexOf(n);if(3!==t.nodeType||!t.textContent||0!==t.textContent.trim().length){G.set(t,e),i.length||(Q.set(e,!1),[].slice.call(e.childNodes).forEach(function(t){return e.__removeChild(t)}));var o=!Q.get(e);r>-1?(o&&e.__insertBefore(t,n),i.splice(r,0,t)):(o&&e.__appendChild(t),i.push(t)),e.____triggerSlotChangeEvent()}}function v(e){var n=e.assignedSlot;if(n){var i=n.getAssignedNodes(),r=i.indexOf(e);if(r>-1){i.splice(r,1),G.set(e,null);var o=!Q.get(n);o&&n.__removeChild(e),i.length||(Q.set(n,!0),t(n,function(e){n.__appendChild(e)})),n.____triggerSlotChangeEvent()}}}function p(e,t){for(var n=e.childNodes,i=n.length,r=0;i>r;r++)if(n[r]===t)return r;return-1}function m(e,t,i,r){var s=p(e,i);n(t,function(t,n){r(t,n),A?Y.set(t,e):o(t,"parentNode",e),s>-1?e.childNodes.splice(s+n,0,t):e.childNodes.push(t)})}function N(e,t,n){var i=p(e,t);i>-1&&(n(t,0),A?Y.set(t,null):o(t,"parentNode",null),e.childNodes.splice(i,1))}function C(e,t,n){m(e,t,n,function(t){e.__insertBefore(t,n)})}function y(e,t,n){m(e,t,n,function(t){var i=U.get(e),r=K.get(i),o=r[_(t)];o&&g(o,t,n)})}function w(e,t,i){n(t,function(t){if(d(t))b(e,t);else{var n=t.querySelectorAll&&t.querySelectorAll("slot");if(n)for(var i=n.length,r=0;i>r;r++)b(e,n[r])}}),C(e,t,i)}function b(e,n){var i=c(n);Q.set(n,!0),K.get(e)[i]=n,t(J.get(e),function(e){e.assignedSlot||i!==_(e)||g(n,e)})}function E(e,t){N(e,t,function(){e.__removeChild(t)})}function S(e,t){N(e,t,function(){v(t)})}function x(e,t){N(e,t,function(){if(d(t))L(e,t);else for(var n=t.querySelectorAll&&t.querySelectorAll("slot"),i=0;i<n.length;i++)L(e,n[i])})}function L(e,t){t.getAssignedNodes().forEach(v),delete K.get(e)[c(t)]}function T(e,t,n){var i=l(e),r=t.parentNode;return A||e.childNodes.push||o(e,"childNodes",[]),r&&"host"===l(r)&&(A?Y.set(t,null):o(t,"parentNode",null)),"node"===i?A?e.__insertBefore(t,n):C(e,t,n):"slot"===i?C(e,t,n):"host"===i?y(e,t,n):"root"===i?w(e,t,n):void 0}function j(e){for(var t=0;t<R.length;t++){var n=window[R[t]];if(n){var i=n.prototype;if(i.hasOwnProperty(e))return Object.getOwnPropertyDescriptor(i,e)}}}var A=!!Object.getOwnPropertyDescriptor(window.Node.prototype,"parentNode").get,O=e(function(e){function t(){return(new Date).getTime()}e.exports=Date.now||t}),k=O&&"object"==typeof O&&"default"in O?O["default"]:O,M=e(function(e){var t=k;e.exports=function(e,n,i){function r(){var d=t()-l;n>d&&d>0?o=setTimeout(r,n-d):(o=null,i||(a=e.apply(u,s),o||(u=s=null)))}var o,s,u,l,a;return null==n&&(n=100),function(){u=this,s=arguments,l=t();var d=i&&!o;return o||(o=setTimeout(r,n)),d&&(a=e.apply(u,s),u=s=null),a}}}),P=M&&"object"==typeof M&&"default"in M?M["default"]:M,D="0.0.1",B=window.WeakMap||function(){function e(){this.key="____weak_map_"+t++}var t=0;return e.prototype={"delete":function(e){e&&delete e[this.key]},get:function(e){return e?e[this.key]:null},has:function(e){return e?"undefined"!=typeof e[this.key]:!1},set:function(e,t){if(e){var n=this.key;"undefined"==typeof e[n]?Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value:t}):e[n]=t}}},e}(),H="_shadow_root_",q=H.toUpperCase(),F=["childNodes","parentNode"],R=["Node","Element","EventTarget"],z=new B,I=new B,U=new B,W=new B,Y=new B,G=new B,J=new B,K=new B,Q=new B,V=new DOMParser,X={____assignedNodes:{get:function(){return this.______assignedNodes||(this.______assignedNodes=[])}},____isInFallbackMode:{get:function(){return Q.get(this)}},____slotChangeListeners:{get:function(){return"undefined"==typeof this.______slotChangeListeners&&(this.______slotChangeListeners=0),this.______slotChangeListeners},set:function(e){this.______slotChangeListeners=e}},____triggerSlotChangeEvent:{value:P(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 T(this,e)}},assignedSlot:{get:function(){return G.get(this)||null}},attachShadow:{value:function(e){var n=this,i=e&&e.mode;if("closed"!==i&&"open"!==i)throw new Error('You must specify { mode } as "open" or "closed" to attachShadow().');var r=U.get(this);if(r)return r;var s=u([].slice.call(this.childNodes)),l=document.createElement(e.polyfillShadowRootTagName||H);return I.set(this,i),U.set(this,l),J.set(l,this),K.set(l,{}),A?W.set(this,s):o(this,"childNodes",s),t(this,function(e){return n.__removeChild(e)}),this.__appendChild(l)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(A&&"node"===l(this))return this.__childNodes;var e=W.get(this);return e||W.set(this,e=u([])),e}},children:{get:function(){var e=[];return t(this,function(t){1===t.nodeType&&e.push(t)}),u(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},getAssignedNodes:{value:function(){if(d(this)){var e=z.get(this);return e||z.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="";return t(this,function(t){e+=1===t.nodeType?t.outerHTML:t.textContent}),e},set:function(e){for(var t=r(e);this.hasChildNodes();)this.removeChild(this.firstChild);for(;t.hasChildNodes();){var n=t.firstChild;t.removeChild(n),this.appendChild(n)}}},insertBefore:{value:function(e,t){return T(this,e,t)}},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 t(this.parentNode,function(t,n,i){return e===t?i[n+1]||null:void 0})}},nextElementSibling:{get:function(){var e=this,n=void 0;return t(this.parentNode,function(t){return n&&1===t.nodeType?t:void(e===t&&(n=!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+">"}},parentElement:{get:function(){return f(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return Y.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return t(this.parentNode,function(t,n,i){return e===t?i[n-1]||null:void 0})}},previousElementSibling:{get:function(){var e=this,n=void 0;return t(this.parentNode,function(t){return n&&e===t?n:void(1===t.nodeType&&(n=t))})}},removeChild:{value:function(e){var t=l(this);return"node"===t?A?this.__removeChild(e):E(this,e):"slot"===t?E(this,e):"host"===t?S(this,e):"root"===t?x(this,e):void 0}},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"===I.get(this)?U.get(this):null}},textContent:{get:function(){var e="";return t(this,function(t){e+=t.textContent}),e},set:function(e){for(;this.hasChildNodes();)this.removeChild(this.firstChild);this.appendChild(document.createTextNode(e))}}};"attachShadow"in document.createElement("div")||!function(){var e=HTMLElement.prototype;Object.keys(X).forEach(function(t){var n=X[t];if(n.configurable=!0,A||-1===F.indexOf(t)){var i=j(t);Object.defineProperty(e,t,n),i&&i.configurable&&Object.defineProperty(e,"__"+t,i)}})}();var Z=Object.freeze({"default":D}),$=window.skatejsNamedSlots;D.noConflict=function(){return window.skatejsNamedSlots=$,this},window.skatejsNamedSlots=D;for(var ee in Z)D[ee]=Z[ee];return D.version="0.1.5",D});
//# sourceMappingURL=index.min.js.map

@@ -155,2 +155,7 @@ (function (global, factory) {

var slotInsertBeforeIndex = assignedNodes.indexOf(insertBefore);
if (node.nodeType === 3 && node.textContent && node.textContent.trim().length === 0) {
return;
}
nodeToSlotMap.set(node, slot);

@@ -284,6 +289,9 @@

var slotNodes = node.querySelectorAll && node.querySelectorAll('slot');
var slotNodesLen = slotNodes.length;
for (var a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
if (slotNodes) {
var slotNodesLen = slotNodes.length;
for (var a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
}
}

@@ -290,0 +298,0 @@ }

{
"name": "skatejs-named-slots",
"version": "0.1.4",
"version": "0.1.5",
"description": "A polygap (partial polyfill) for the Shadow DOM Named Slot API.",

@@ -32,3 +32,3 @@ "main": "lib/index.js",

"gulp": "gulpjs/gulp#73eced0",
"skatejs-build": "skatejs/build#4e97e35"
"skatejs-build": "skatejs/build#6c4bf30"
},

@@ -35,0 +35,0 @@ "dependencies": {

@@ -146,2 +146,21 @@ import { eachChildNode, eachNodeOrFragmentNodes } from './util/each';

// Don't slot nodes that have content but are only whitespace. This is an
// anomaly that I don't think the spec deals with.
//
// The problem is:
//
// - If you insert HTML with indentation into the page, there will be
// whitespace and if that's inserted it messes with fallback content
// calculation where there is formatting, but no meaningful content, so in
// theory it should fallback. Since you can attach a shadow root after we
// mean to insert an empty text node and have it "count", we can't really
// discard nodes that are considered formatting at the time of attachment.
// - You can insert a text node and modify its text content later.
// Incremental DOM seems to do this. Every way I look at it, it seems
// problematic that we should have to screen for content, but I don't seems
// much of a way around it at the moment.
if (node.nodeType === 3 && node.textContent && node.textContent.trim().length === 0) {
return;
}
nodeToSlotMap.set(node, slot);

@@ -277,5 +296,7 @@

const slotNodes = node.querySelectorAll && node.querySelectorAll('slot');
const slotNodesLen = slotNodes.length;
for (let a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
if (slotNodes) {
const slotNodesLen = slotNodes.length;
for (let a = 0; a < slotNodesLen; a++) {
addSlotToRoot(root, slotNodes[a]);
}
}

@@ -282,0 +303,0 @@ }

@@ -96,2 +96,7 @@ import '../../../src/index';

});
it('adding non-element nodes should not cause an error', function () {
const text = document.createTextNode('test');
root.appendChild(text);
});
});

@@ -98,0 +103,0 @@

@@ -97,2 +97,17 @@ import '../../../src/index';

});
it('should not slot text nodes that are empty or have only whitespace', function () {
const host = create('div');
const root = host.attachShadow({ mode: 'closed' });
const slot = create('slot');
root.appendChild(slot);
host.appendChild(document.createTextNode(''));
host.appendChild(document.createTextNode(' '));
host.appendChild(document.createTextNode('\n'));
host.appendChild(document.createTextNode('testing'));
expect(slot.getAssignedNodes().length).to.equal(2);
expect(slot.getAssignedNodes()[0].textContent).to.equal('');
expect(slot.getAssignedNodes()[1].textContent).to.equal('testing');
});
});

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