skatejs-named-slots
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -717,11 +717,11 @@ (function (global, factory) { | ||
function syncSlotChildNodes(firstChild) { | ||
if (canPatchNativeAccessors && getNodeType(firstChild) === 'slot' && firstChild.__childNodes.length !== firstChild.childNodes.length) { | ||
while (firstChild.hasChildNodes()) { | ||
firstChild.removeChild(firstChild.firstChild); | ||
function syncSlotChildNodes(node) { | ||
if (canPatchNativeAccessors && getNodeType(node) === 'slot' && node.__childNodes.length !== node.childNodes.length) { | ||
while (node.hasChildNodes()) { | ||
node.removeChild(node.firstChild); | ||
} | ||
for (var i = 0; i < firstChild.__childNodes.length; i++) { | ||
firstChild.appendChild(firstChild.__childNodes[i]); | ||
} | ||
forEach.call(node.__childNodes, function (child) { | ||
return node.appendChild(child); | ||
}); | ||
} | ||
@@ -776,3 +776,4 @@ } | ||
value: function value(newNode) { | ||
return appendChildOrInsertBefore(this, newNode); | ||
appendChildOrInsertBefore(this, newNode); | ||
return newNode; | ||
} | ||
@@ -930,10 +931,13 @@ }, | ||
// when we are doing this: root.innerHTML = "<slot><div></div></slot>"; | ||
// slot.__childNodes is out of sync with slot.childNodes. | ||
// to fix it we have to manually remove and insert them | ||
var slots = parsed.querySelectorAll('slot'); | ||
forEach.call(slots, function (slot) { | ||
return syncSlotChildNodes(slot); | ||
}); | ||
while (parsed.hasChildNodes()) { | ||
var firstChild = parsed.firstChild; | ||
// when we are doing this: root.innerHTML = "<slot><div></div></slot>"; | ||
// slot.__childNodes is out of sync with slot.childNodes. | ||
// to fix it we have to manually remove and insert them | ||
syncSlotChildNodes(firstChild); | ||
// When we polyfill everything on HTMLElement.prototype, we overwrite | ||
@@ -953,3 +957,5 @@ // properties. This makes it so that parentNode reports null even though | ||
value: function value(newNode, refNode) { | ||
return appendChildOrInsertBefore(this, newNode, refNode); | ||
appendChildOrInsertBefore(this, newNode, refNode); | ||
return newNode; | ||
} | ||
@@ -1062,21 +1068,20 @@ }, | ||
if (nodeType === 'node') { | ||
if (canPatchNativeAccessors) { | ||
return this.__removeChild(refNode); | ||
} | ||
return removeNodeFromNode(this, refNode); | ||
switch (nodeType) { | ||
case 'node': | ||
if (canPatchNativeAccessors) { | ||
return this.__removeChild(refNode); | ||
} | ||
removeNodeFromNode(this, refNode); | ||
break; | ||
case 'slot': | ||
removeNodeFromSlot(this, refNode); | ||
break; | ||
case 'host': | ||
removeNodeFromHost(this, refNode); | ||
break; | ||
case 'root': | ||
removeNodeFromRoot(this, refNode); | ||
break; | ||
} | ||
if (nodeType === 'slot') { | ||
return removeNodeFromSlot(this, refNode); | ||
} | ||
if (nodeType === 'host') { | ||
return removeNodeFromHost(this, refNode); | ||
} | ||
if (nodeType === 'root') { | ||
return removeNodeFromRoot(this, refNode); | ||
} | ||
return refNode; | ||
} | ||
@@ -1083,0 +1088,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.skatejsNamedSlots=e.skatejsNamedSlots||{})}(this,function(e){function t(e,t){return t={exports:{}},e(t,t.exports),t.exports}function n(e,t){if(e)for(var n=e.childNodes,r=n.length,i=0;r>i;i++){var o=t(n[i],i,n);if("undefined"!=typeof o)return o}}function r(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,r=n.length,i=0;r>i;i++)t(n[i],i);else t(e,0)}function i(e,t){for(var n=void 0;e&&!(n=Object.getOwnPropertyDescriptor(e,t));)e=Object.getPrototypeOf(e);return n}function o(e,t){e instanceof Node&&(e=B);var n=i(e,t);if(n){var r=n.get,o=n.set,s={configurable:!0,enumerable:!0};if(r)return s.get=r,s.set=o,s;if("function"==typeof e[t])return s.value=e[t],s}var u=Object.getOwnPropertyDescriptor(e,t);return u&&u.get?u:void 0}function s(e){return e.textContent.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function u(e){return e.text||"<!--"+e.textContent+"-->"}function a(e){var t=document.createElement("div");if(F)return t.__innerHTML=e,t;for(var n=ve.parseFromString("<div>"+e+"</div>","text/html").body.firstChild;n.hasChildNodes();){var r=n.firstChild;n.removeChild(r),t.appendChild(r)}return document.importNode(t,!0)}function l(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function d(e){return this[e]}function c(e){return e.item=d,e}function h(e){return!!ue.get(e)}function f(e){return"SLOT"===e.tagName}function v(e){return e.tagName===Z}function p(e){return h(e)?"host":f(e)?"slot":v(e)?"root":"node"}function _(e,t){for(;e&&e!==document;){if(t(e))return e;e=e.parentNode}}function g(e){return e.getAttribute&&e.getAttribute("name")||"default"}function m(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function N(e,t,n){if((3!==t.nodeType||!t.textContent||0!==t.textContent.trim().length)&&-1!==ie.indexOf(t.nodeType)){var r=e.assignedNodes(),i=0===r.length,o=r.indexOf(n);de.set(t,e),i&&Q.call(e.childNodes,function(t){return e.__removeChild(t)}),o>-1?(e.__insertBefore(t,void 0!==n?n:null),r.splice(o,0,t)):(e.__appendChild(t),r.push(t)),e.____triggerSlotChangeEvent()}}function C(e){var t=e.assignedSlot;if(t){var n=t.assignedNodes(),r=n.indexOf(e);if(r>-1){var i=1===n.length;n.splice(r,1),de.set(e,null),t.__removeChild(e),i&&Q.call(t.childNodes,function(e){return t.__appendChild(e)}),t.____triggerSlotChangeEvent()}}}function y(e,t){for(var n=e.childNodes,r=n.length,i=0;r>i;i++)if(n[i]===t)return i;return-1}function b(e,t,n,i){var o=y(e,n);r(t,function(t,n){i(t,n),F?le.set(t,e):l(t,"parentNode",e),o>-1?K.splice.call(e.childNodes,o+n,0,t):K.push.call(e.childNodes,t)})}function E(e,t,n){var r=y(e,t);r>-1&&(n(t,0),F?le.set(t,null):l(t,"parentNode",null),K.splice.call(e.childNodes,r,1))}function w(e,t,n){b(e,t,n,function(t){e.__insertBefore(t,void 0!==n?n:null)})}function x(e,t,n){b(e,t,n,function(t){var r=ue.get(e),i=he.get(r),o=i[m(t)];o&&N(o,t,n)})}function O(e,t){var r=g(t);F||t.childNodes.push||l(t,"childNodes",[].concat(H.toConsumableArray(t.childNodes))),he.get(e)[r]=t,fe.has(t)||fe.set(t,e),n(ce.get(e),function(e){e.assignedSlot||r!==m(e)||N(t,e)})}function T(e,t,n){r(t,function(t){if(f(t))O(e,t);else{var n=t.querySelectorAll&&t.querySelectorAll("slot");if(n)for(var r=n.length,i=0;r>i;i++)O(e,n[i])}}),w(e,t,n)}function M(e,t,n){var r=0===e.assignedNodes().length;b(e,t,n,function(t){r&&e.__insertBefore(t,void 0!==n?n:null)})}function L(e,t){var n=0===e.assignedNodes().length;E(e,t,function(){n&&e.__removeChild(t)})}function S(e,t){E(e,t,function(){e.__removeChild(t)})}function j(e,t){E(e,t,function(){C(t)})}function A(e,t){t.assignedNodes().forEach(C),delete he.get(e)[g(t)],fe["delete"](t)}function P(e,t){E(e,t,function(){if(f(t))A(e,t);else{var n=t.querySelectorAll&&t.querySelectorAll("slot");if(n)for(var r=0;r<n.length;r++)A(e,n[r])}e.__removeChild(t)})}function k(e){if(v(e))return e;if(e.parentNode)return k(e.parentNode)}function D(e,t,n){var r=p(e),i=t.parentNode,o=k(e);return F||e.childNodes.push||l(e,"childNodes",[].concat(H.toConsumableArray(e.childNodes))),o&&"slot"===p(t)&&O(o,t),i&&"host"===p(i)&&(F?le.set(t,null):l(t,"parentNode",null)),"node"===r?F?(le.set(t,e),e.__insertBefore(t,void 0!==n?n:null)):w(e,t,n):"slot"===r?M(e,t,n):"host"===r?x(e,t,n):"root"===r?T(e,t,n):void 0}function W(e){if(F&&"slot"===p(e)&&e.__childNodes.length!==e.childNodes.length){for(;e.hasChildNodes();)e.removeChild(e.firstChild);for(var t=0;t<e.__childNodes.length;t++)e.appendChild(e.__childNodes[t])}}var H={};H.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};var B=document.createElement("div"),q=o(Element.prototype,"innerHTML"),F=!!q,R=t(function(e){function t(){return(new Date).getTime()}e.exports=Date.now||t}),I=R&&"object"==typeof R&&"default"in R?R["default"]:R,U=t(function(e){var t=I;e.exports=function(e,n,r){function i(){var d=t()-a;n>d&&d>0?o=setTimeout(i,n-d):(o=null,r||(l=e.apply(u,s),o||(u=s=null)))}var o,s,u,a,l;return null==n&&(n=100),function(){u=this,s=arguments,a=t();var d=r&&!o;return o||(o=setTimeout(i,n)),d&&(l=e.apply(u,s),u=s=null),l}}}),X=U&&"object"==typeof U&&"default"in U?U["default"]:U,Y="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 r=t[this.name];return r&&r[0]===t?r[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):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}();try{var z=new window.CustomEvent("test",{bubbles:!1,cancelable:!0,detail:{x:"y"}});if(z.preventDefault(),z.defaultPrevented!==!0)throw new Error("Could not prevent default")}catch(G){var J=function(e,t){var n;t=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail);var r=n.preventDefault;return n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},n};J.prototype=window.Event.prototype,window.CustomEvent=J}var K=Array.prototype,Q=K.forEach,V="_shadow_root_",Z=V.toUpperCase(),$=["childNodes","parentNode"],ee=["textContent"],te=["assignedSlot"],ne=["textContent"],re=[],ie=[Node.ELEMENT_NODE,Node.TEXT_NODE],oe=new WeakMap,se=new WeakMap,ue=new WeakMap,ae=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakMap,he=new WeakMap,fe=new WeakMap,ve=new DOMParser,pe={____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:X(function(){this.____slotChangeListeners&&this.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1}))})},addEventListener:{value:function(e,t,n){return"slotchange"===e&&f(this)&&this.____slotChangeListeners++,this.__addEventListener(e,t,n)}},appendChild:{value:function(e){return D(this,e)}},assignedSlot:{get:function(){var e=de.get(this);if(!e)return null;var t=fe.get(e),n=ce.get(t),r=se.get(n);return"open"===r?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 r=ue.get(this);if(r)return r;var i=c([].slice.call(this.childNodes)),o=document.createElement(e.polyfillShadowRootTagName||V);return se.set(this,n),ue.set(this,o),ce.set(o,this),he.set(o,{}),F?ae.set(this,i):l(this,"childNodes",i),i.forEach(function(e){t.__removeChild(e),F?le.set(e,t):l(e,"parentNode",t)}),this.__appendChild(o)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(F&&"node"===p(this))return this.__childNodes;var e=ae.get(this);return e||ae.set(this,e=c([])),e}},children:{get:function(){var e=[];return n(this,function(t){1===t.nodeType&&e.push(t)}),c(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},assignedNodes:{value:function(){if(f(this)){var e=oe.get(this);return e||oe.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="",t=function(e){return e.outerHTML},r={1:t,3:s,8:u};return n(this,function(n){var i=r[n.nodeType]||t;e+=i(n)}),e},set:function(e){for(var t=a(e);this.hasChildNodes();)this.removeChild(this.firstChild);for(;t.hasChildNodes();){var n=t.firstChild;W(n),t.removeChild(n),this.appendChild(n)}}},insertBefore:{value:function(e,t){return D(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 n(this.parentNode,function(t,n,r){return e===t?r[n+1]||null:void 0})}},nextElementSibling:{get:function(){var e=this,t=void 0;return n(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=a(e);this.parentNode.replaceChild(t.firstChild,this)}else{if(!F)throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");this.__outerHTML=e}}},parentElement:{get:function(){return _(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return le.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return n(this.parentNode,function(t,n,r){return e===t?r[n-1]||null:void 0})}},previousElementSibling:{get:function(){var e=this,t=void 0;return n(this.parentNode,function(n){return t&&e===n?t:void(1===n.nodeType&&(t=n))})}},removeChild:{value:function(e){var t=p(this);return"node"===t?F?this.__removeChild(e):S(this,e):"slot"===t?L(this,e):"host"===t?j(this,e):"root"===t?P(this,e):void 0}},removeEventListener:{value:function(e,t,n){return"slotchange"===e&&this.____slotChangeListeners&&f(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"===se.get(this)?ue.get(this):null}},textContent:{get:function(){var e="";return n(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=HTMLElement.prototype,t=Text.prototype,n=Comment.prototype,r=document.createTextNode(""),i=document.createComment("");Object.keys(pe).forEach(function(s){var u=pe[s];if(u.configurable=!0,u.hasOwnProperty("value")&&(u.writable=!0),F||-1===$.indexOf(s)){var a=o(e,s),l=o(t,s),d=o(n,s),c=s in r&&-1===ee.indexOf(s)||~te.indexOf(s),h=s in i&&-1===ne.indexOf(s)||~re.indexOf(s),f="__"+s;Object.defineProperty(e,s,u),a&&Object.defineProperty(e,f,a),c&&Object.defineProperty(t,s,u),c&&l&&Object.defineProperty(t,f,l),h&&Object.defineProperty(n,s,u),h&&d&&Object.defineProperty(n,f,d)}})}(),e["default"]=Y}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.skatejsNamedSlots=e.skatejsNamedSlots||{})}(this,function(e){function t(e,t){return t={exports:{}},e(t,t.exports),t.exports}function n(e,t){if(e)for(var n=e.childNodes,r=n.length,i=0;r>i;i++){var o=t(n[i],i,n);if("undefined"!=typeof o)return o}}function r(e,t){if(e instanceof DocumentFragment)for(var n=e.childNodes,r=n.length,i=0;r>i;i++)t(n[i],i);else t(e,0)}function i(e,t){for(var n=void 0;e&&!(n=Object.getOwnPropertyDescriptor(e,t));)e=Object.getPrototypeOf(e);return n}function o(e,t){e instanceof Node&&(e=B);var n=i(e,t);if(n){var r=n.get,o=n.set,s={configurable:!0,enumerable:!0};if(r)return s.get=r,s.set=o,s;if("function"==typeof e[t])return s.value=e[t],s}var u=Object.getOwnPropertyDescriptor(e,t);return u&&u.get?u:void 0}function s(e){return e.textContent.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function u(e){return e.text||"<!--"+e.textContent+"-->"}function a(e){var t=document.createElement("div");if(F)return t.__innerHTML=e,t;for(var n=ve.parseFromString("<div>"+e+"</div>","text/html").body.firstChild;n.hasChildNodes();){var r=n.firstChild;n.removeChild(r),t.appendChild(r)}return document.importNode(t,!0)}function l(e,t,n){Object.defineProperty(e,t,{configurable:!0,get:function(){return n}})}function d(e){return this[e]}function c(e){return e.item=d,e}function h(e){return!!ue.get(e)}function f(e){return"SLOT"===e.tagName}function v(e){return e.tagName===Z}function p(e){return h(e)?"host":f(e)?"slot":v(e)?"root":"node"}function _(e,t){for(;e&&e!==document;){if(t(e))return e;e=e.parentNode}}function g(e){return e.getAttribute&&e.getAttribute("name")||"default"}function m(e){return e.getAttribute&&e.getAttribute("slot")||"default"}function N(e,t,n){if((3!==t.nodeType||!t.textContent||0!==t.textContent.trim().length)&&-1!==ie.indexOf(t.nodeType)){var r=e.assignedNodes(),i=0===r.length,o=r.indexOf(n);de.set(t,e),i&&Q.call(e.childNodes,function(t){return e.__removeChild(t)}),o>-1?(e.__insertBefore(t,void 0!==n?n:null),r.splice(o,0,t)):(e.__appendChild(t),r.push(t)),e.____triggerSlotChangeEvent()}}function C(e){var t=e.assignedSlot;if(t){var n=t.assignedNodes(),r=n.indexOf(e);if(r>-1){var i=1===n.length;n.splice(r,1),de.set(e,null),t.__removeChild(e),i&&Q.call(t.childNodes,function(e){return t.__appendChild(e)}),t.____triggerSlotChangeEvent()}}}function y(e,t){for(var n=e.childNodes,r=n.length,i=0;r>i;i++)if(n[i]===t)return i;return-1}function b(e,t,n,i){var o=y(e,n);r(t,function(t,n){i(t,n),F?le.set(t,e):l(t,"parentNode",e),o>-1?K.splice.call(e.childNodes,o+n,0,t):K.push.call(e.childNodes,t)})}function E(e,t,n){var r=y(e,t);r>-1&&(n(t,0),F?le.set(t,null):l(t,"parentNode",null),K.splice.call(e.childNodes,r,1))}function w(e,t,n){b(e,t,n,function(t){e.__insertBefore(t,void 0!==n?n:null)})}function x(e,t,n){b(e,t,n,function(t){var r=ue.get(e),i=he.get(r),o=i[m(t)];o&&N(o,t,n)})}function O(e,t){var r=g(t);F||t.childNodes.push||l(t,"childNodes",[].concat(H.toConsumableArray(t.childNodes))),he.get(e)[r]=t,fe.has(t)||fe.set(t,e),n(ce.get(e),function(e){e.assignedSlot||r!==m(e)||N(t,e)})}function T(e,t,n){r(t,function(t){if(f(t))O(e,t);else{var n=t.querySelectorAll&&t.querySelectorAll("slot");if(n)for(var r=n.length,i=0;r>i;i++)O(e,n[i])}}),w(e,t,n)}function M(e,t,n){var r=0===e.assignedNodes().length;b(e,t,n,function(t){r&&e.__insertBefore(t,void 0!==n?n:null)})}function L(e,t){var n=0===e.assignedNodes().length;E(e,t,function(){n&&e.__removeChild(t)})}function S(e,t){E(e,t,function(){e.__removeChild(t)})}function A(e,t){E(e,t,function(){C(t)})}function j(e,t){t.assignedNodes().forEach(C),delete he.get(e)[g(t)],fe["delete"](t)}function k(e,t){E(e,t,function(){if(f(t))j(e,t);else{var n=t.querySelectorAll&&t.querySelectorAll("slot");if(n)for(var r=0;r<n.length;r++)j(e,n[r])}e.__removeChild(t)})}function P(e){if(v(e))return e;if(e.parentNode)return P(e.parentNode)}function D(e,t,n){var r=p(e),i=t.parentNode,o=P(e);return F||e.childNodes.push||l(e,"childNodes",[].concat(H.toConsumableArray(e.childNodes))),o&&"slot"===p(t)&&O(o,t),i&&"host"===p(i)&&(F?le.set(t,null):l(t,"parentNode",null)),"node"===r?F?(le.set(t,e),e.__insertBefore(t,void 0!==n?n:null)):w(e,t,n):"slot"===r?M(e,t,n):"host"===r?x(e,t,n):"root"===r?T(e,t,n):void 0}function W(e){if(F&&"slot"===p(e)&&e.__childNodes.length!==e.childNodes.length){for(;e.hasChildNodes();)e.removeChild(e.firstChild);Q.call(e.__childNodes,function(t){return e.appendChild(t)})}}var H={};H.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};var B=document.createElement("div"),q=o(Element.prototype,"innerHTML"),F=!!q,R=t(function(e){function t(){return(new Date).getTime()}e.exports=Date.now||t}),I=R&&"object"==typeof R&&"default"in R?R["default"]:R,U=t(function(e){var t=I;e.exports=function(e,n,r){function i(){var d=t()-a;n>d&&d>0?o=setTimeout(i,n-d):(o=null,r||(l=e.apply(u,s),o||(u=s=null)))}var o,s,u,a,l;return null==n&&(n=100),function(){u=this,s=arguments,a=t();var d=r&&!o;return o||(o=setTimeout(i,n)),d&&(l=e.apply(u,s),u=s=null),l}}}),X=U&&"object"==typeof U&&"default"in U?U["default"]:U,Y="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 r=t[this.name];return r&&r[0]===t?r[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):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}();try{var z=new window.CustomEvent("test",{bubbles:!1,cancelable:!0,detail:{x:"y"}});if(z.preventDefault(),z.defaultPrevented!==!0)throw new Error("Could not prevent default")}catch(G){var J=function(e,t){var n;t=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail);var r=n.preventDefault;return n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},n};J.prototype=window.Event.prototype,window.CustomEvent=J}var K=Array.prototype,Q=K.forEach,V="_shadow_root_",Z=V.toUpperCase(),$=["childNodes","parentNode"],ee=["textContent"],te=["assignedSlot"],ne=["textContent"],re=[],ie=[Node.ELEMENT_NODE,Node.TEXT_NODE],oe=new WeakMap,se=new WeakMap,ue=new WeakMap,ae=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakMap,he=new WeakMap,fe=new WeakMap,ve=new DOMParser,pe={____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:X(function(){this.____slotChangeListeners&&this.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1}))})},addEventListener:{value:function(e,t,n){return"slotchange"===e&&f(this)&&this.____slotChangeListeners++,this.__addEventListener(e,t,n)}},appendChild:{value:function(e){return D(this,e),e}},assignedSlot:{get:function(){var e=de.get(this);if(!e)return null;var t=fe.get(e),n=ce.get(t),r=se.get(n);return"open"===r?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 r=ue.get(this);if(r)return r;var i=c([].slice.call(this.childNodes)),o=document.createElement(e.polyfillShadowRootTagName||V);return se.set(this,n),ue.set(this,o),ce.set(o,this),he.set(o,{}),F?ae.set(this,i):l(this,"childNodes",i),i.forEach(function(e){t.__removeChild(e),F?le.set(e,t):l(e,"parentNode",t)}),this.__appendChild(o)}},childElementCount:{get:function(){return this.children.length}},childNodes:{get:function(){if(F&&"node"===p(this))return this.__childNodes;var e=ae.get(this);return e||ae.set(this,e=c([])),e}},children:{get:function(){var e=[];return n(this,function(t){1===t.nodeType&&e.push(t)}),c(e)}},firstChild:{get:function(){return this.childNodes[0]||null}},firstElementChild:{get:function(){return this.children[0]||null}},assignedNodes:{value:function(){if(f(this)){var e=oe.get(this);return e||oe.set(this,e=[]),e}}},hasChildNodes:{value:function(){return this.childNodes.length>0}},innerHTML:{get:function(){var e="",t=function(e){return e.outerHTML},r={1:t,3:s,8:u};return n(this,function(n){var i=r[n.nodeType]||t;e+=i(n)}),e},set:function(e){for(var t=a(e);this.hasChildNodes();)this.removeChild(this.firstChild);var n=t.querySelectorAll("slot");for(Q.call(n,function(e){return W(e)});t.hasChildNodes();){var r=t.firstChild;t.removeChild(r),this.appendChild(r)}}},insertBefore:{value:function(e,t){return D(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 n(this.parentNode,function(t,n,r){return e===t?r[n+1]||null:void 0})}},nextElementSibling:{get:function(){var e=this,t=void 0;return n(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=a(e);this.parentNode.replaceChild(t.firstChild,this)}else{if(!F)throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");this.__outerHTML=e}}},parentElement:{get:function(){return _(this.parentNode,function(e){return 1===e.nodeType})}},parentNode:{get:function(){return le.get(this)||this.__parentNode||null}},previousSibling:{get:function(){var e=this;return n(this.parentNode,function(t,n,r){return e===t?r[n-1]||null:void 0})}},previousElementSibling:{get:function(){var e=this,t=void 0;return n(this.parentNode,function(n){return t&&e===n?t:void(1===n.nodeType&&(t=n))})}},removeChild:{value:function(e){var t=p(this);switch(t){case"node":if(F)return this.__removeChild(e);S(this,e);break;case"slot":L(this,e);break;case"host":A(this,e);break;case"root":k(this,e)}return e}},removeEventListener:{value:function(e,t,n){return"slotchange"===e&&this.____slotChangeListeners&&f(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"===se.get(this)?ue.get(this):null}},textContent:{get:function(){var e="";return n(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=HTMLElement.prototype,t=Text.prototype,n=Comment.prototype,r=document.createTextNode(""),i=document.createComment("");Object.keys(pe).forEach(function(s){var u=pe[s];if(u.configurable=!0,u.hasOwnProperty("value")&&(u.writable=!0),F||-1===$.indexOf(s)){var a=o(e,s),l=o(t,s),d=o(n,s),c=s in r&&-1===ee.indexOf(s)||~te.indexOf(s),h=s in i&&-1===ne.indexOf(s)||~re.indexOf(s),f="__"+s;Object.defineProperty(e,s,u),a&&Object.defineProperty(e,f,a),c&&Object.defineProperty(t,s,u),c&&l&&Object.defineProperty(t,f,l),h&&Object.defineProperty(n,s,u),h&&d&&Object.defineProperty(n,f,d)}})}(),e["default"]=Y}); | ||
//# sourceMappingURL=index.min.js.map |
@@ -50,3 +50,3 @@ { | ||
}, | ||
"version": "0.2.4" | ||
"version": "0.2.5" | ||
} |
@@ -444,11 +444,9 @@ import { eachChildNode, eachNodeOrFragmentNodes } from './util/each'; | ||
function syncSlotChildNodes(firstChild) { | ||
if (canPatchNativeAccessors && getNodeType(firstChild) === 'slot' && (firstChild.__childNodes.length !== firstChild.childNodes.length)) { | ||
while (firstChild.hasChildNodes()) { | ||
firstChild.removeChild(firstChild.firstChild); | ||
function syncSlotChildNodes(node) { | ||
if (canPatchNativeAccessors && getNodeType(node) === 'slot' && (node.__childNodes.length !== node.childNodes.length)) { | ||
while (node.hasChildNodes()) { | ||
node.removeChild(node.firstChild); | ||
} | ||
for (let i = 0; i < firstChild.__childNodes.length; i++) { | ||
firstChild.appendChild(firstChild.__childNodes[i]); | ||
} | ||
forEach.call(node.__childNodes, child => node.appendChild(child)); | ||
} | ||
@@ -503,3 +501,4 @@ } | ||
value(newNode) { | ||
return appendChildOrInsertBefore(this, newNode); | ||
appendChildOrInsertBefore(this, newNode); | ||
return newNode; | ||
}, | ||
@@ -653,10 +652,11 @@ }, | ||
// when we are doing this: root.innerHTML = "<slot><div></div></slot>"; | ||
// slot.__childNodes is out of sync with slot.childNodes. | ||
// to fix it we have to manually remove and insert them | ||
const slots = parsed.querySelectorAll('slot'); | ||
forEach.call(slots, slot => syncSlotChildNodes(slot)); | ||
while (parsed.hasChildNodes()) { | ||
const firstChild = parsed.firstChild; | ||
// when we are doing this: root.innerHTML = "<slot><div></div></slot>"; | ||
// slot.__childNodes is out of sync with slot.childNodes. | ||
// to fix it we have to manually remove and insert them | ||
syncSlotChildNodes(firstChild); | ||
// When we polyfill everything on HTMLElement.prototype, we overwrite | ||
@@ -676,3 +676,5 @@ // properties. This makes it so that parentNode reports null even though | ||
value(newNode, refNode) { | ||
return appendChildOrInsertBefore(this, newNode, refNode); | ||
appendChildOrInsertBefore(this, newNode, refNode); | ||
return newNode; | ||
}, | ||
@@ -784,21 +786,20 @@ }, | ||
if (nodeType === 'node') { | ||
if (canPatchNativeAccessors) { | ||
return this.__removeChild(refNode); | ||
} | ||
return removeNodeFromNode(this, refNode); | ||
switch (nodeType) { | ||
case 'node': | ||
if (canPatchNativeAccessors) { | ||
return this.__removeChild(refNode); | ||
} | ||
removeNodeFromNode(this, refNode); | ||
break; | ||
case 'slot': | ||
removeNodeFromSlot(this, refNode); | ||
break; | ||
case 'host': | ||
removeNodeFromHost(this, refNode); | ||
break; | ||
case 'root': | ||
removeNodeFromRoot(this, refNode); | ||
break; | ||
} | ||
if (nodeType === 'slot') { | ||
return removeNodeFromSlot(this, refNode); | ||
} | ||
if (nodeType === 'host') { | ||
return removeNodeFromHost(this, refNode); | ||
} | ||
if (nodeType === 'root') { | ||
return removeNodeFromRoot(this, refNode); | ||
} | ||
return refNode; | ||
}, | ||
@@ -805,0 +806,0 @@ }, |
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
188662
1923