UNPKG

@shirtiny/mira

Version:
2 lines (1 loc) 839 B
var p=t=>typeof t=="number"||typeof t=="string",u=t=>typeof t=="function",m=t=>t instanceof Object,d={isText:p,isFn:u,isObject:m},c=d;var f=(t,n)=>{Object.keys(t).forEach(e=>{e!=="children"&&(e.startsWith("on")?n.addEventListener(e.substring(2).toLowerCase(),t[e]):n[e]=t[e])})},a=(t,n)=>{if(!n)return;let o=c.isFn(t.type)?t.type(t.props):t;if(!o)return;let{type:e,props:s}=o,r=e===""?document.createTextNode(""):document.createElement(e);f(s,r),(s.children||[]).forEach(l=>a(l,r)),n.appendChild(r)},y=a;var x=t=>({type:"",props:{nodeValue:t+""}}),F=(t,n,...o)=>{let e=Object.assign({},n),s=o.length>0?[].concat(...o):[];return e.children=s.filter(r=>r!=null&&r!==!1).map(r=>c.isText(r)?x(r):r),{type:t,props:e,key:""}},D=t=>t.children;var T=(t,n)=>t+n;export{D as Fragment,T as add,F as createElement,x as createTextElement,y as render};