UNPKG

uce-loader

Version:

A minimalistic, framework agnostic, lazy Custom Elements loader

2 lines (1 loc) 644 B
self.uceLoader=function(e){"use strict";const t=/^(?:annotation-xml|color-profile|font-face(?:|-format|-name|-src|-uri)|missing-glyph)$/i,n=new Set;return e.default=e=>{const o=e.container||document,r=o=>{for(let r=0,{length:c}=o;r<c;r++)for(let{addedNodes:c}=o[r],a=0,{length:d}=c;a<d;a++){const o=c[a],{children:r,getAttribute:d,tagName:i}=o;if(d){const c=(d.call(o,"is")||i).toLowerCase();0<c.indexOf("-")&&!n.has(c)&&!t.test(c)&&(n.add(c),customElements.get(c)||e.on(c)),s(r)}}},s=e=>{r([{addedNodes:e}])};s([document==o?o.documentElement:o]);const c=new MutationObserver(r);return c.observe(o,{subtree:!0,childList:!0}),c},e}({}).default;