as-custom-element
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -17,14 +17,11 @@ 'use strict'; | ||
const invoke = (nodes, key, nested) => { | ||
const invoke = (nodes, key, parsed) => { | ||
for (let i = 0, {length} = nodes; i < length; i++) { | ||
const target = nodes[i]; | ||
if (nested) { | ||
if ('querySelectorAll' in target) { | ||
if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, !nested); | ||
} | ||
if (!parsed.has(target) && 'querySelectorAll' in target) { | ||
parsed.add(target); | ||
if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, parsed); | ||
} | ||
else if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
} | ||
@@ -34,7 +31,7 @@ }; | ||
const mainLoop = records => { | ||
for (let i = 0, {length} = records; i < length; i++) { | ||
for (let parsed = new Set, i = 0, {length} = records; i < length; i++) { | ||
const {addedNodes, removedNodes} = records[i]; | ||
invoke(addedNodes, 'c', true); | ||
invoke(addedNodes, 'c', parsed); | ||
attributeChanged(sao.takeRecords()); | ||
invoke(removedNodes, 'd', true); | ||
invoke(removedNodes, 'd', parsed); | ||
} | ||
@@ -41,0 +38,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
self.asCustomElement=function(e){"use strict";const t=new Set,r=new MutationObserver(e=>{t.forEach(a,e)});function a(e){e(this,r)}r.observe(document,{subtree:!0,childList:!0}),t.observer=r;const o=new WeakMap,{observer:n}=t,c=e=>{for(let t=0,{length:r}=e;t<r;t++){const{target:r,attributeName:a,oldValue:n}=e[t],c=r.getAttribute(a);o.get(r).a[a].forEach(e=>{e.call(r,a,n,c)})}},l=(e,t,r)=>{for(let a=0,{length:n}=e;a<n;a++){const n=e[a];r?"querySelectorAll"in n&&(o.has(n)&&o.get(n)[t].forEach(u,n),l(n.querySelectorAll("*"),t,!r)):o.has(n)&&o.get(n)[t].forEach(u,n)}},s=e=>{for(let t=0,{length:r}=e;t<r;t++){const{addedNodes:r,removedNodes:a}=e[t];l(r,"c",!0),c(d.takeRecords()),l(a,"d",!0)}},d=new MutationObserver(c);t.add(s);function u(e){e.call(this)}return e.default=(e,{connectedCallback:t,disconnectedCallback:r,observedAttributes:a,attributeChangedCallback:c})=>{s(n.takeRecords());const{a:l,c:u,d:i}=o.get(e)||(e=>{const t={a:{},c:new Set,d:new Set};return o.set(e,t),t})(e);return a&&(d.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:a}),a.forEach(t=>{(l[t]||(l[t]=new Set)).add(c),e.hasAttribute(t)&&c.call(e,t,null,e.getAttribute(t))})),r&&i.add(r),t&&(u.add(t),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||t.call(e)),e},e}({}).default; | ||
self.asCustomElement=function(e){"use strict";const t=new Set,r=new MutationObserver(e=>{t.forEach(a,e)});function a(e){e(this,r)}r.observe(document,{subtree:!0,childList:!0}),t.observer=r;const n=new WeakMap,{observer:o}=t,c=e=>{for(let t=0,{length:r}=e;t<r;t++){const{target:r,attributeName:a,oldValue:o}=e[t],c=r.getAttribute(a);n.get(r).a[a].forEach(e=>{e.call(r,a,o,c)})}},l=(e,t,r)=>{for(let a=0,{length:o}=e;a<o;a++){const o=e[a];!r.has(o)&&"querySelectorAll"in o&&(r.add(o),n.has(o)&&n.get(o)[t].forEach(u,o),l(o.querySelectorAll("*"),t,r))}},s=e=>{for(let t=new Set,r=0,{length:a}=e;r<a;r++){const{addedNodes:a,removedNodes:n}=e[r];l(a,"c",t),c(d.takeRecords()),l(n,"d",t)}},d=new MutationObserver(c);t.add(s);function u(e){e.call(this)}return e.default=(e,{connectedCallback:t,disconnectedCallback:r,observedAttributes:a,attributeChangedCallback:c})=>{s(o.takeRecords());const{a:l,c:u,d:i}=n.get(e)||(e=>{const t={a:{},c:new Set,d:new Set};return n.set(e,t),t})(e);return a&&(d.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:a}),a.forEach(t=>{(l[t]||(l[t]=new Set)).add(c),e.hasAttribute(t)&&c.call(e,t,null,e.getAttribute(t))})),r&&i.add(r),t&&(u.add(t),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||t.call(e)),e},e}({}).default; |
@@ -16,14 +16,11 @@ import sdo from 'shared-document-observer'; | ||
const invoke = (nodes, key, nested) => { | ||
const invoke = (nodes, key, parsed) => { | ||
for (let i = 0, {length} = nodes; i < length; i++) { | ||
const target = nodes[i]; | ||
if (nested) { | ||
if ('querySelectorAll' in target) { | ||
if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, !nested); | ||
} | ||
if (!parsed.has(target) && 'querySelectorAll' in target) { | ||
parsed.add(target); | ||
if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, parsed); | ||
} | ||
else if (wm.has(target)) | ||
wm.get(target)[key].forEach(call, target); | ||
} | ||
@@ -33,7 +30,7 @@ }; | ||
const mainLoop = records => { | ||
for (let i = 0, {length} = records; i < length; i++) { | ||
for (let parsed = new Set, i = 0, {length} = records; i < length; i++) { | ||
const {addedNodes, removedNodes} = records[i]; | ||
invoke(addedNodes, 'c', true); | ||
invoke(addedNodes, 'c', parsed); | ||
attributeChanged(sao.takeRecords()); | ||
invoke(removedNodes, 'd', true); | ||
invoke(removedNodes, 'd', parsed); | ||
} | ||
@@ -40,0 +37,0 @@ }; |
19
index.js
@@ -38,12 +38,11 @@ self.asCustomElement = (function (exports) { | ||
var invoke$1 = function invoke(nodes, key, nested) { | ||
var invoke$1 = function invoke(nodes, key, parsed) { | ||
for (var i = 0, length = nodes.length; i < length; i++) { | ||
var target = nodes[i]; | ||
if (nested) { | ||
if ('querySelectorAll' in target) { | ||
if (wm.has(target)) wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, !nested); | ||
} | ||
} else if (wm.has(target)) wm.get(target)[key].forEach(call, target); | ||
if (!parsed.has(target) && 'querySelectorAll' in target) { | ||
parsed.add(target); | ||
if (wm.has(target)) wm.get(target)[key].forEach(call, target); | ||
invoke(target.querySelectorAll('*'), key, parsed); | ||
} | ||
} | ||
@@ -53,9 +52,9 @@ }; | ||
var mainLoop = function mainLoop(records) { | ||
for (var i = 0, length = records.length; i < length; i++) { | ||
for (var parsed = new Set(), i = 0, length = records.length; i < length; i++) { | ||
var _records$i2 = records[i], | ||
addedNodes = _records$i2.addedNodes, | ||
removedNodes = _records$i2.removedNodes; | ||
invoke$1(addedNodes, 'c', true); | ||
invoke$1(addedNodes, 'c', parsed); | ||
attributeChanged(sao.takeRecords()); | ||
invoke$1(removedNodes, 'd', true); | ||
invoke$1(removedNodes, 'd', parsed); | ||
} | ||
@@ -62,0 +61,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
self.asCustomElement=function(e){"use strict";var t=new Set,r=new MutationObserver((function(e){t.forEach(a,e)}));function a(e){e(this,r)}r.observe(document,{subtree:!0,childList:!0}),t.observer=r;var n=new WeakMap,o=t.observer,c=function(e){for(var t=function(t,r){var a=e[t],o=a.target,c=a.attributeName,u=a.oldValue,l=o.getAttribute(c);n.get(o).a[c].forEach((function(e){e.call(o,c,u,l)}))},r=0,a=e.length;r<a;r++)t(r)},u=function e(t,r,a){for(var o=0,c=t.length;o<c;o++){var u=t[o];a?"querySelectorAll"in u&&(n.has(u)&&n.get(u)[r].forEach(d,u),e(u.querySelectorAll("*"),r,!a)):n.has(u)&&n.get(u)[r].forEach(d,u)}},l=function(e){for(var t=0,r=e.length;t<r;t++){var a=e[t],n=a.addedNodes,o=a.removedNodes;u(n,"c",!0),c(i.takeRecords()),u(o,"d",!0)}},i=new MutationObserver(c);t.add(l);function d(e){e.call(this)}return e.default=function(e,t){var r=t.connectedCallback,a=t.disconnectedCallback,c=t.observedAttributes,u=t.attributeChangedCallback;l(o.takeRecords());var d=n.get(e)||function(e){var t={a:{},c:new Set,d:new Set};return n.set(e,t),t}(e),s=d.a,f=d.c,b=d.d;return c&&(i.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:c}),c.forEach((function(t){(s[t]||(s[t]=new Set)).add(u),e.hasAttribute(t)&&u.call(e,t,null,e.getAttribute(t))}))),a&&b.add(a),r&&(f.add(r),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||r.call(e)),e},e}({}).default; | ||
self.asCustomElement=function(e){"use strict";var t=new Set,r=new MutationObserver((function(e){t.forEach(a,e)}));function a(e){e(this,r)}r.observe(document,{subtree:!0,childList:!0}),t.observer=r;var n=new WeakMap,o=t.observer,c=function(e){for(var t=function(t,r){var a=e[t],o=a.target,c=a.attributeName,u=a.oldValue,l=o.getAttribute(c);n.get(o).a[c].forEach((function(e){e.call(o,c,u,l)}))},r=0,a=e.length;r<a;r++)t(r)},u=function e(t,r,a){for(var o=0,c=t.length;o<c;o++){var u=t[o];!a.has(u)&&"querySelectorAll"in u&&(a.add(u),n.has(u)&&n.get(u)[r].forEach(d,u),e(u.querySelectorAll("*"),r,a))}},l=function(e){for(var t=new Set,r=0,a=e.length;r<a;r++){var n=e[r],o=n.addedNodes,l=n.removedNodes;u(o,"c",t),c(i.takeRecords()),u(l,"d",t)}},i=new MutationObserver(c);t.add(l);function d(e){e.call(this)}return e.default=function(e,t){var r=t.connectedCallback,a=t.disconnectedCallback,c=t.observedAttributes,u=t.attributeChangedCallback;l(o.takeRecords());var d=n.get(e)||function(e){var t={a:{},c:new Set,d:new Set};return n.set(e,t),t}(e),s=d.a,f=d.c,b=d.d;return c&&(i.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:c}),c.forEach((function(t){(s[t]||(s[t]=new Set)).add(u),e.hasAttribute(t)&&u.call(e,t,null,e.getAttribute(t))}))),a&&b.add(a),r&&(f.add(r),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||r.call(e)),e},e}({}).default; |
{ | ||
"name": "as-custom-element", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Setup any element as if it was a Custom Element", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
14511
272