UNPKG

grapper

Version:

Data Visualization Microframework

1 lines 784 B
/* grapper - 1.1.0-beta.3 [plugin.object] */ (()=>{var c="_$tag",i="_$children",a=t=>({[c]:u(t),[i]:d(t),...m(t)}),f=(t,e)=>{b(t,e),l(t,e)},m=t=>t.getAttributeNames().reduce((e,n)=>(e[n]=t[n](),e),{}),g=t=>Object.keys(t).filter(e=>![c,i].includes(e)),b=(t,e)=>g(e).forEach(n=>t[n](e[n])),u=t=>t.tagName().toLowerCase(),d=t=>t.children().map(e=>a(e)),l=(t,e)=>(e[i]||[]).forEach(n=>{let s=t.append(n[c]);g(n).forEach(r=>s[r](n[r])),l(s,n)});function h(t){t.extendTemplate&&t.extendTemplate.defineDirective({name:"g-object",exec(e,{expr:n,evalExpr:s,data:r}){e.fromObject(s(n,r))}}),t.extendInstance({toObject(){return a(this)},fromObject(e){return f(this,e)}})}var o=h;globalThis.gSVG&&globalThis.gSVG.install(o);customElements.whenDefined("grapper-view").then(t=>{t.install(o)});})();