Socket
Socket
Sign inDemoInstall

@webreflection/custom-elements-builtin

Package Overview
Dependencies
4
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

116

cjs/index.js

@@ -115,75 +115,57 @@ 'use strict';

defineProperty(document, 'createElement', {
configurable: true,
value(name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
const element = createElement.call(document, name);
if (is)
element.setAttribute('is', is);
return element;
document.createElement = function (name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
});
const element = createElement.call(document, name);
if (is)
element.setAttribute('is', is);
return element;
};
defineProperty(customElements, 'get', {
configurable: true,
value: getCE
});
defineProperty(customElements, 'whenDefined', {
configurable: true,
value: whenDefined
});
defineProperty(customElements, 'upgrade', {
configurable: true,
value(element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
customElements.get = getCE;
customElements.whenDefined = whenDefined;
customElements.upgrade = function (element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
upgrade.call(customElements, element);
}
});
defineProperty(customElements, 'define', {
configurable: true,
value(is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
upgrade.call(customElements, element);
};
customElements.define = function (is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
parse(document.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
parse(document.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else
parseShadowed(document.querySelectorAll(selector));
});
defined.get(is)._(Class);
}
});
else
parseShadowed(document.querySelectorAll(selector));
});
defined.get(is)._(Class);
};

@@ -190,0 +172,0 @@ function parseShadow(element) {

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

!function(){"use strict";const{keys:e}=Object,t=!0,r=!1,o="querySelectorAll",n="querySelectorAll",{document:l,Element:s,MutationObserver:a,Set:c,WeakMap:u}=self,i=e=>n in e,{filter:d}=[];var h=e=>{const h=new u,f=(t,r)=>{let o;if(r)for(let n,l=(e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector)(t),s=0,{length:a}=p;s<a;s++)l.call(t,n=p[s])&&(h.has(t)||h.set(t,new c),o=h.get(t),o.has(n)||(o.add(n),e.handle(t,r,n)));else h.has(t)&&(o=h.get(t),h.delete(t),o.forEach((o=>{e.handle(t,r,o)})))},g=(e,t=!0)=>{for(let r=0,{length:o}=e;r<o;r++)f(e[r],t)},{query:p}=e,b=e.root||l,y=((e,n=document,l=MutationObserver,s=["*"])=>{const a=(r,n,l,s,c,u)=>{for(const i of r)(u||o in i)&&(c?l.has(i)||(l.add(i),s.delete(i),e(i,c)):s.has(i)||(s.add(i),l.delete(i),e(i,c)),u||a(i[o](n),n,l,s,c,t))},c=new l((e=>{if(s.length){const o=s.join(","),n=new Set,l=new Set;for(const{addedNodes:s,removedNodes:c}of e)a(c,o,n,l,r,r),a(s,o,n,l,t,r)}})),{observe:u}=c;return(c.observe=e=>u.call(c,e,{subtree:t,childList:t}))(n),c})(f,b,a,p),{attachShadow:w}=s.prototype;return w&&(s.prototype.attachShadow=function(e){const t=w.call(this,e);return y.observe(t),t}),p.length&&g(b[n](p)),{drop:e=>{for(let t=0,{length:r}=e;t<r;t++)h.delete(e[t])},flush:()=>{const e=y.takeRecords();for(let t=0,{length:r}=e;t<r;t++)g(d.call(e[t].removedNodes,i),!1),g(d.call(e[t].addedNodes,i),!0)},observer:y,parse:g}};const{customElements:f,document:g,Element:p,MutationObserver:b,Object:y,Promise:w,Map:m,Set:v,WeakMap:S,Reflect:A}=self,{createElement:E}=g,{define:M,get:O,upgrade:q}=f,{construct:k}=A||{construct(e){return e.call(this)}},{defineProperty:N,getOwnPropertyNames:$,setPrototypeOf:P}=y,C=new S,j=new v,V=new m,L=new m,R=new m,T=new m,W=[],_=[],x=e=>T.get(e)||O.call(f,e),{parse:D}=h({query:_,handle:(t,r,o)=>{const n=R.get(o);if(r&&!n.isPrototypeOf(t)){const r=(t=>{const r=e(t),o=[],{length:n}=r;for(let e=0;e<n;e++)o[e]=t[r[e]],delete t[r[e]];return()=>{for(let e=0;e<n;e++)t[r[e]]=o[e]}})(t);B=P(t,n);try{new n.constructor}finally{B=null,r()}}const l=(r?"":"dis")+"connectedCallback";l in n&&t[l]()}}),{parse:F}=h({query:W,handle(e,t){C.has(e)&&(t?j.add(e):j.delete(e),_.length&&G.call(_,e))}}),{attachShadow:H}=p.prototype;H&&(p.prototype.attachShadow=function(e){const t=H.call(this,e);return C.set(this,t),t});const I=e=>{if(!L.has(e)){let t,r=new w((e=>{t=e}));L.set(e,{$:r,_:t})}return L.get(e).$},z=((e,t)=>{const r=e=>{for(let t=0,{length:r}=e;t<r;t++)o(e[t])},o=({target:e,attributeName:t,oldValue:r})=>{e.attributeChangedCallback(t,r,e.getAttribute(t))};return(n,l)=>{const{observedAttributes:s}=n.constructor;return s&&e(l).then((()=>{new t(r).observe(n,{attributes:!0,attributeOldValue:!0,attributeFilter:s});for(let e=0,{length:t}=s;e<t;e++)n.hasAttribute(s[e])&&o({target:n,attributeName:s[e],oldValue:null})})),n}})(I,b);let B=null;function G(e){const t=C.get(e);D(t.querySelectorAll(this),e.isConnected)}$(self).filter((e=>/^HTML.*Element$/.test(e))).forEach((e=>{const t=self[e];function r(){const{constructor:e}=this;if(!V.has(e))throw new TypeError("Illegal constructor");const{is:r,tag:o}=V.get(e);if(r){if(B)return z(B,r);const t=E.call(g,o);return t.setAttribute("is",r),z(P(t,e.prototype),r)}return k.call(this,t,[],e)}P(r,t),N(r.prototype=t.prototype,"constructor",{value:r}),N(self,e,{value:r})})),N(g,"createElement",{configurable:!0,value(e,t){const r=t&&t.is;if(r){const t=T.get(r);if(t&&V.get(t).tag===e)return new t}const o=E.call(g,e);return r&&o.setAttribute("is",r),o}}),N(f,"get",{configurable:!0,value:x}),N(f,"whenDefined",{configurable:!0,value:I}),N(f,"upgrade",{configurable:!0,value(e){const t=e.getAttribute("is");if(t){const r=T.get(t);if(r)return void z(P(e,r.prototype),t)}q.call(f,e)}}),N(f,"define",{configurable:!0,value(e,t,r){if(x(e))throw new Error(`'${e}' has already been defined as a custom element`);let o;const n=r&&r.extends;V.set(t,n?{is:e,tag:n}:{is:"",tag:e}),n?(o=`${n}[is="${e}"]`,R.set(o,t.prototype),T.set(e,t),_.push(o)):(M.apply(f,arguments),W.push(o=e)),I(e).then((()=>{n?(D(g.querySelectorAll(o)),j.forEach(G,[o])):F(g.querySelectorAll(o))})),L.get(e)._(t)}})}();
!function(){"use strict";const{keys:e}=Object,t=!0,r=!1,n="querySelectorAll",o="querySelectorAll",{document:l,Element:s,MutationObserver:a,Set:c,WeakMap:u}=self,i=e=>o in e,{filter:d}=[];var h=e=>{const h=new u,f=(t,r)=>{let n;if(r)for(let o,l=(e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector)(t),s=0,{length:a}=p;s<a;s++)l.call(t,o=p[s])&&(h.has(t)||h.set(t,new c),n=h.get(t),n.has(o)||(n.add(o),e.handle(t,r,o)));else h.has(t)&&(n=h.get(t),h.delete(t),n.forEach((n=>{e.handle(t,r,n)})))},g=(e,t=!0)=>{for(let r=0,{length:n}=e;r<n;r++)f(e[r],t)},{query:p}=e,b=e.root||l,y=((e,o=document,l=MutationObserver,s=["*"])=>{const a=(r,o,l,s,c,u)=>{for(const i of r)(u||n in i)&&(c?l.has(i)||(l.add(i),s.delete(i),e(i,c)):s.has(i)||(s.add(i),l.delete(i),e(i,c)),u||a(i[n](o),o,l,s,c,t))},c=new l((e=>{if(s.length){const n=s.join(","),o=new Set,l=new Set;for(const{addedNodes:s,removedNodes:c}of e)a(c,n,o,l,r,r),a(s,n,o,l,t,r)}})),{observe:u}=c;return(c.observe=e=>u.call(c,e,{subtree:t,childList:t}))(o),c})(f,b,a,p),{attachShadow:w}=s.prototype;return w&&(s.prototype.attachShadow=function(e){const t=w.call(this,e);return y.observe(t),t}),p.length&&g(b[o](p)),{drop:e=>{for(let t=0,{length:r}=e;t<r;t++)h.delete(e[t])},flush:()=>{const e=y.takeRecords();for(let t=0,{length:r}=e;t<r;t++)g(d.call(e[t].removedNodes,i),!1),g(d.call(e[t].addedNodes,i),!0)},observer:y,parse:g}};const{customElements:f,document:g,Element:p,MutationObserver:b,Object:y,Promise:w,Map:m,Set:v,WeakMap:S,Reflect:A}=self,{createElement:E}=g,{define:M,get:O,upgrade:q}=f,{construct:k}=A||{construct(e){return e.call(this)}},{defineProperty:N,getOwnPropertyNames:$,setPrototypeOf:P}=y,C=new S,j=new v,V=new m,L=new m,R=new m,T=new m,W=[],_=[],x=e=>T.get(e)||O.call(f,e),{parse:D}=h({query:_,handle:(t,r,n)=>{const o=R.get(n);if(r&&!o.isPrototypeOf(t)){const r=(t=>{const r=e(t),n=[],{length:o}=r;for(let e=0;e<o;e++)n[e]=t[r[e]],delete t[r[e]];return()=>{for(let e=0;e<o;e++)t[r[e]]=n[e]}})(t);B=P(t,o);try{new o.constructor}finally{B=null,r()}}const l=(r?"":"dis")+"connectedCallback";l in o&&t[l]()}}),{parse:F}=h({query:W,handle(e,t){C.has(e)&&(t?j.add(e):j.delete(e),_.length&&G.call(_,e))}}),{attachShadow:H}=p.prototype;H&&(p.prototype.attachShadow=function(e){const t=H.call(this,e);return C.set(this,t),t});const I=e=>{if(!L.has(e)){let t,r=new w((e=>{t=e}));L.set(e,{$:r,_:t})}return L.get(e).$},z=((e,t)=>{const r=e=>{for(let t=0,{length:r}=e;t<r;t++)n(e[t])},n=({target:e,attributeName:t,oldValue:r})=>{e.attributeChangedCallback(t,r,e.getAttribute(t))};return(o,l)=>{const{observedAttributes:s}=o.constructor;return s&&e(l).then((()=>{new t(r).observe(o,{attributes:!0,attributeOldValue:!0,attributeFilter:s});for(let e=0,{length:t}=s;e<t;e++)o.hasAttribute(s[e])&&n({target:o,attributeName:s[e],oldValue:null})})),o}})(I,b);let B=null;function G(e){const t=C.get(e);D(t.querySelectorAll(this),e.isConnected)}$(self).filter((e=>/^HTML.*Element$/.test(e))).forEach((e=>{const t=self[e];function r(){const{constructor:e}=this;if(!V.has(e))throw new TypeError("Illegal constructor");const{is:r,tag:n}=V.get(e);if(r){if(B)return z(B,r);const t=E.call(g,n);return t.setAttribute("is",r),z(P(t,e.prototype),r)}return k.call(this,t,[],e)}P(r,t),N(r.prototype=t.prototype,"constructor",{value:r}),N(self,e,{value:r})})),g.createElement=function(e,t){const r=t&&t.is;if(r){const t=T.get(r);if(t&&V.get(t).tag===e)return new t}const n=E.call(g,e);return r&&n.setAttribute("is",r),n},f.get=x,f.whenDefined=I,f.upgrade=function(e){const t=e.getAttribute("is");if(t){const r=T.get(t);if(r)return void z(P(e,r.prototype),t)}q.call(f,e)},f.define=function(e,t,r){if(x(e))throw new Error(`'${e}' has already been defined as a custom element`);let n;const o=r&&r.extends;V.set(t,o?{is:e,tag:o}:{is:"",tag:e}),o?(n=`${o}[is="${e}"]`,R.set(n,t.prototype),T.set(e,t),_.push(n)):(M.apply(f,arguments),W.push(n=e)),I(e).then((()=>{o?(D(g.querySelectorAll(n)),j.forEach(G,[n])):F(g.querySelectorAll(n))})),L.get(e)._(t)}}();

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

const{keys:e}=Object,t="querySelectorAll",r="querySelectorAll",{document:o,Element:n,MutationObserver:l,Set:s,WeakMap:a}=self,c=e=>r in e,{filter:u}=[];var i=e=>{const i=new a,d=(t,r)=>{let o;if(r)for(let n,l=(e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector)(t),a=0,{length:c}=f;a<c;a++)l.call(t,n=f[a])&&(i.has(t)||i.set(t,new s),o=i.get(t),o.has(n)||(o.add(n),e.handle(t,r,n)));else i.has(t)&&(o=i.get(t),i.delete(t),o.forEach((o=>{e.handle(t,r,o)})))},h=(e,t=!0)=>{for(let r=0,{length:o}=e;r<o;r++)d(e[r],t)},{query:f}=e,g=e.root||o,p=((e,r=document,o=MutationObserver,n=["*"])=>{const l=(r,o,n,s,a,c)=>{for(const u of r)(c||t in u)&&(a?n.has(u)||(n.add(u),s.delete(u),e(u,a)):s.has(u)||(s.add(u),n.delete(u),e(u,a)),c||l(u[t](o),o,n,s,a,!0))},s=new o((e=>{if(n.length){const t=n.join(","),r=new Set,o=new Set;for(const{addedNodes:n,removedNodes:s}of e)l(s,t,r,o,!1,!1),l(n,t,r,o,!0,!1)}})),{observe:a}=s;return(s.observe=e=>a.call(s,e,{subtree:!0,childList:!0}))(r),s})(d,g,l,f),{attachShadow:b}=n.prototype;return b&&(n.prototype.attachShadow=function(e){const t=b.call(this,e);return p.observe(t),t}),f.length&&h(g[r](f)),{drop:e=>{for(let t=0,{length:r}=e;t<r;t++)i.delete(e[t])},flush:()=>{const e=p.takeRecords();for(let t=0,{length:r}=e;t<r;t++)h(u.call(e[t].removedNodes,c),!1),h(u.call(e[t].addedNodes,c),!0)},observer:p,parse:h}};const{customElements:d,document:h,Element:f,MutationObserver:g,Object:p,Promise:b,Map:y,Set:w,WeakMap:m,Reflect:v}=self,{createElement:S}=h,{define:A,get:E,upgrade:M}=d,{construct:O}=v||{construct(e){return e.call(this)}},{defineProperty:q,getOwnPropertyNames:k,setPrototypeOf:N}=p,$=new m,P=new w,C=new y,j=new y,V=new y,L=new y,R=[],T=[],W=e=>L.get(e)||E.call(d,e),{parse:_}=i({query:T,handle:(t,r,o)=>{const n=V.get(o);if(r&&!n.isPrototypeOf(t)){const r=(t=>{const r=e(t),o=[],{length:n}=r;for(let e=0;e<n;e++)o[e]=t[r[e]],delete t[r[e]];return()=>{for(let e=0;e<n;e++)t[r[e]]=o[e]}})(t);I=N(t,n);try{new n.constructor}finally{I=null,r()}}const l=(r?"":"dis")+"connectedCallback";l in n&&t[l]()}}),{parse:x}=i({query:R,handle(e,t){$.has(e)&&(t?P.add(e):P.delete(e),T.length&&z.call(T,e))}}),{attachShadow:D}=f.prototype;D&&(f.prototype.attachShadow=function(e){const t=D.call(this,e);return $.set(this,t),t});const F=e=>{if(!j.has(e)){let t,r=new b((e=>{t=e}));j.set(e,{$:r,_:t})}return j.get(e).$},H=((e,t)=>{const r=e=>{for(let t=0,{length:r}=e;t<r;t++)o(e[t])},o=({target:e,attributeName:t,oldValue:r})=>{e.attributeChangedCallback(t,r,e.getAttribute(t))};return(n,l)=>{const{observedAttributes:s}=n.constructor;return s&&e(l).then((()=>{new t(r).observe(n,{attributes:!0,attributeOldValue:!0,attributeFilter:s});for(let e=0,{length:t}=s;e<t;e++)n.hasAttribute(s[e])&&o({target:n,attributeName:s[e],oldValue:null})})),n}})(F,g);let I=null;function z(e){const t=$.get(e);_(t.querySelectorAll(this),e.isConnected)}k(self).filter((e=>/^HTML.*Element$/.test(e))).forEach((e=>{const t=self[e];function r(){const{constructor:e}=this;if(!C.has(e))throw new TypeError("Illegal constructor");const{is:r,tag:o}=C.get(e);if(r){if(I)return H(I,r);const t=S.call(h,o);return t.setAttribute("is",r),H(N(t,e.prototype),r)}return O.call(this,t,[],e)}N(r,t),q(r.prototype=t.prototype,"constructor",{value:r}),q(self,e,{value:r})})),q(h,"createElement",{configurable:!0,value(e,t){const r=t&&t.is;if(r){const t=L.get(r);if(t&&C.get(t).tag===e)return new t}const o=S.call(h,e);return r&&o.setAttribute("is",r),o}}),q(d,"get",{configurable:!0,value:W}),q(d,"whenDefined",{configurable:!0,value:F}),q(d,"upgrade",{configurable:!0,value(e){const t=e.getAttribute("is");if(t){const r=L.get(t);if(r)return void H(N(e,r.prototype),t)}M.call(d,e)}}),q(d,"define",{configurable:!0,value(e,t,r){if(W(e))throw new Error(`'${e}' has already been defined as a custom element`);let o;const n=r&&r.extends;C.set(t,n?{is:e,tag:n}:{is:"",tag:e}),n?(o=`${n}[is="${e}"]`,V.set(o,t.prototype),L.set(e,t),T.push(o)):(A.apply(d,arguments),R.push(o=e)),F(e).then((()=>{n?(_(h.querySelectorAll(o)),P.forEach(z,[o])):x(h.querySelectorAll(o))})),j.get(e)._(t)}});
const{keys:e}=Object,t=!0,r=!1,n="querySelectorAll",o="querySelectorAll",{document:l,Element:s,MutationObserver:a,Set:c,WeakMap:u}=self,i=e=>o in e,{filter:d}=[];var h=e=>{const h=new u,f=(t,r)=>{let n;if(r)for(let o,l=(e=>e.matches||e.webkitMatchesSelector||e.msMatchesSelector)(t),s=0,{length:a}=p;s<a;s++)l.call(t,o=p[s])&&(h.has(t)||h.set(t,new c),n=h.get(t),n.has(o)||(n.add(o),e.handle(t,r,o)));else h.has(t)&&(n=h.get(t),h.delete(t),n.forEach((n=>{e.handle(t,r,n)})))},g=(e,t=!0)=>{for(let r=0,{length:n}=e;r<n;r++)f(e[r],t)},{query:p}=e,b=e.root||l,y=((e,o=document,l=MutationObserver,s=["*"])=>{const a=(r,o,l,s,c,u)=>{for(const i of r)(u||n in i)&&(c?l.has(i)||(l.add(i),s.delete(i),e(i,c)):s.has(i)||(s.add(i),l.delete(i),e(i,c)),u||a(i[n](o),o,l,s,c,t))},c=new l((e=>{if(s.length){const n=s.join(","),o=new Set,l=new Set;for(const{addedNodes:s,removedNodes:c}of e)a(c,n,o,l,r,r),a(s,n,o,l,t,r)}})),{observe:u}=c;return(c.observe=e=>u.call(c,e,{subtree:t,childList:t}))(o),c})(f,b,a,p),{attachShadow:w}=s.prototype;return w&&(s.prototype.attachShadow=function(e){const t=w.call(this,e);return y.observe(t),t}),p.length&&g(b[o](p)),{drop:e=>{for(let t=0,{length:r}=e;t<r;t++)h.delete(e[t])},flush:()=>{const e=y.takeRecords();for(let t=0,{length:r}=e;t<r;t++)g(d.call(e[t].removedNodes,i),!1),g(d.call(e[t].addedNodes,i),!0)},observer:y,parse:g}};const{customElements:f,document:g,Element:p,MutationObserver:b,Object:y,Promise:w,Map:m,Set:v,WeakMap:S,Reflect:A}=self,{createElement:E}=g,{define:M,get:O,upgrade:q}=f,{construct:k}=A||{construct(e){return e.call(this)}},{defineProperty:N,getOwnPropertyNames:$,setPrototypeOf:P}=y,C=new S,j=new v,V=new m,L=new m,R=new m,T=new m,W=[],_=[],x=e=>T.get(e)||O.call(f,e),{parse:D}=h({query:_,handle:(t,r,n)=>{const o=R.get(n);if(r&&!o.isPrototypeOf(t)){const r=(t=>{const r=e(t),n=[],{length:o}=r;for(let e=0;e<o;e++)n[e]=t[r[e]],delete t[r[e]];return()=>{for(let e=0;e<o;e++)t[r[e]]=n[e]}})(t);B=P(t,o);try{new o.constructor}finally{B=null,r()}}const l=(r?"":"dis")+"connectedCallback";l in o&&t[l]()}}),{parse:F}=h({query:W,handle(e,t){C.has(e)&&(t?j.add(e):j.delete(e),_.length&&G.call(_,e))}}),{attachShadow:H}=p.prototype;H&&(p.prototype.attachShadow=function(e){const t=H.call(this,e);return C.set(this,t),t});const I=e=>{if(!L.has(e)){let t,r=new w((e=>{t=e}));L.set(e,{$:r,_:t})}return L.get(e).$},z=((e,t)=>{const r=e=>{for(let t=0,{length:r}=e;t<r;t++)n(e[t])},n=({target:e,attributeName:t,oldValue:r})=>{e.attributeChangedCallback(t,r,e.getAttribute(t))};return(o,l)=>{const{observedAttributes:s}=o.constructor;return s&&e(l).then((()=>{new t(r).observe(o,{attributes:!0,attributeOldValue:!0,attributeFilter:s});for(let e=0,{length:t}=s;e<t;e++)o.hasAttribute(s[e])&&n({target:o,attributeName:s[e],oldValue:null})})),o}})(I,b);let B=null;function G(e){const t=C.get(e);D(t.querySelectorAll(this),e.isConnected)}$(self).filter((e=>/^HTML.*Element$/.test(e))).forEach((e=>{const t=self[e];function r(){const{constructor:e}=this;if(!V.has(e))throw new TypeError("Illegal constructor");const{is:r,tag:n}=V.get(e);if(r){if(B)return z(B,r);const t=E.call(g,n);return t.setAttribute("is",r),z(P(t,e.prototype),r)}return k.call(this,t,[],e)}P(r,t),N(r.prototype=t.prototype,"constructor",{value:r}),N(self,e,{value:r})})),g.createElement=function(e,t){const r=t&&t.is;if(r){const t=T.get(r);if(t&&V.get(t).tag===e)return new t}const n=E.call(g,e);return r&&n.setAttribute("is",r),n},f.get=x,f.whenDefined=I,f.upgrade=function(e){const t=e.getAttribute("is");if(t){const r=T.get(t);if(r)return void z(P(e,r.prototype),t)}q.call(f,e)},f.define=function(e,t,r){if(x(e))throw new Error(`'${e}' has already been defined as a custom element`);let n;const o=r&&r.extends;V.set(t,o?{is:e,tag:o}:{is:"",tag:e}),o?(n=`${o}[is="${e}"]`,R.set(n,t.prototype),T.set(e,t),_.push(n)):(M.apply(f,arguments),W.push(n=e)),I(e).then((()=>{o?(D(g.querySelectorAll(n)),j.forEach(G,[n])):F(g.querySelectorAll(n))})),L.get(e)._(t)};

@@ -114,75 +114,57 @@ import attributesObserver from '@webreflection/custom-elements-attributes';

defineProperty(document, 'createElement', {
configurable: true,
value(name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
const element = createElement.call(document, name);
if (is)
element.setAttribute('is', is);
return element;
document.createElement = function (name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
});
const element = createElement.call(document, name);
if (is)
element.setAttribute('is', is);
return element;
};
defineProperty(customElements, 'get', {
configurable: true,
value: getCE
});
defineProperty(customElements, 'whenDefined', {
configurable: true,
value: whenDefined
});
defineProperty(customElements, 'upgrade', {
configurable: true,
value(element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
customElements.get = getCE;
customElements.whenDefined = whenDefined;
customElements.upgrade = function (element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
upgrade.call(customElements, element);
}
});
defineProperty(customElements, 'define', {
configurable: true,
value(is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
upgrade.call(customElements, element);
};
customElements.define = function (is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
parse(document.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
parse(document.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else
parseShadowed(document.querySelectorAll(selector));
});
defined.get(is)._(Class);
}
});
else
parseShadowed(document.querySelectorAll(selector));
});
defined.get(is)._(Class);
};

@@ -189,0 +171,0 @@ function parseShadow(element) {

@@ -280,75 +280,57 @@ (function () {

defineProperty(document$1, 'createElement', {
configurable: true,
value(name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
const element = createElement.call(document$1, name);
if (is)
element.setAttribute('is', is);
return element;
document$1.createElement = function (name, options) {
const is = options && options.is;
if (is) {
const Class = registry.get(is);
if (Class && classes.get(Class).tag === name)
return new Class;
}
});
const element = createElement.call(document$1, name);
if (is)
element.setAttribute('is', is);
return element;
};
defineProperty(customElements, 'get', {
configurable: true,
value: getCE
});
defineProperty(customElements, 'whenDefined', {
configurable: true,
value: whenDefined
});
defineProperty(customElements, 'upgrade', {
configurable: true,
value(element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
customElements.get = getCE;
customElements.whenDefined = whenDefined;
customElements.upgrade = function (element) {
const is = element.getAttribute('is');
if (is) {
const constructor = registry.get(is);
if (constructor) {
augment(setPrototypeOf(element, constructor.prototype), is);
// apparently unnecessary because this is handled by qsa observer
// if (element.isConnected && element.connectedCallback)
// element.connectedCallback();
return;
}
upgrade.call(customElements, element);
}
});
defineProperty(customElements, 'define', {
configurable: true,
value(is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
upgrade.call(customElements, element);
};
customElements.define = function (is, Class, options) {
if (getCE(is))
throw new Error(`'${is}' has already been defined as a custom element`);
let selector;
const tag = options && options.extends;
classes.set(Class, tag ? {is, tag} : {is: '', tag: is});
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
selector = `${tag}[is="${is}"]`;
prototypes.set(selector, Class.prototype);
registry.set(is, Class);
query.push(selector);
parse(document$1.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else {
define.apply(customElements, arguments);
shadowed.push(selector = is);
}
whenDefined(is).then(() => {
if (tag) {
parse(document$1.querySelectorAll(selector));
shadows.forEach(parseShadow, [selector]);
}
else
parseShadowed(document$1.querySelectorAll(selector));
});
defined.get(is)._(Class);
}
});
else
parseShadowed(document$1.querySelectorAll(selector));
});
defined.get(is)._(Class);
};

@@ -355,0 +337,0 @@ function parseShadow(element) {

{
"name": "@webreflection/custom-elements-builtin",
"version": "0.3.0",
"version": "0.4.0",
"description": "A better custom-elements-builtin polyfill, Safari only",

@@ -23,6 +23,6 @@ "main": "./cjs/index.js",

"devDependencies": {
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
"ascjs": "^5.0.1",
"rollup": "^2.75.5",
"rollup-plugin-terser": "^7.0.2"
"rollup": "^3.18.0"
},

@@ -37,5 +37,5 @@ "module": "./esm/index.js",

"dependencies": {
"@webreflection/custom-elements-attributes": "^0.1.3",
"@webreflection/custom-elements-upgrade": "^0.1.2",
"qsa-observer": "^3.0.1"
"@webreflection/custom-elements-attributes": "^0.1.4",
"@webreflection/custom-elements-upgrade": "^0.1.3",
"qsa-observer": "^3.0.2"
},

@@ -42,0 +42,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc