-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathkeyed.js
More file actions
2 lines (2 loc) · 5.9 KB
/
Copy pathkeyed.js
File metadata and controls
2 lines (2 loc) · 5.9 KB
1
2
const{isArray:e}=Array,t=[],n=()=>document.createRange(),s=(e,t,n)=>(e.set(t,n),n),r=(e,t,n,s="")=>({t:e,p:t,u:n,n:s}),l=e=>({s:e,t:null,n:null,d:t}),{setPrototypeOf:o}=Object;let i;var c=(e,t,s)=>(i||(i=n()),s?i.setStartAfter(e):i.setStartBefore(e),i.setEndAfter(t),i.deleteContents(),e);const a=({firstChild:e,lastChild:t},n)=>c(e,t,n);let u=!1;const h=(e,t)=>u&&11===e.nodeType?1/t<0?t?a(e,!0):e.lastChild:t?e.valueOf():e.firstChild:e;class d extends((e=>{function t(e){return o(e,new.target.prototype)}return t.prototype=e.prototype,t})(DocumentFragment)){#e;#t;constructor(e){const t=[...e.childNodes];super(e),this.#e=t,this.#t=t.length,u=!0}get firstChild(){return this.#e[0]}get lastChild(){return this.#e.at(-1)}get parentNode(){return this.#e[0].parentNode}remove(){a(this,!1)}replaceWith(e){a(this,!0).replaceWith(e)}valueOf(){return this.childNodes.length!==this.#t&&this.append(...this.#e),this}}const f=(e,t)=>t.reduceRight(p,e),p=(e,t)=>e.childNodes[t];var g=e=>(n,s)=>{const{c:r,e:l,l:o}=e(n,s),i=r.cloneNode(!0);let c,a,u=l.length,h=u?l.slice(0):t;for(;u--;){const{t:e,p:n,u:r,n:o}=l[u],d=n===a?c:c=f(i,a=n),p=8===e?r():r;h[u]={v:p(d,s[u],o,t),u:p,t:d,n:o}}return((e,t)=>({n:e,d:t}))(1===o?i.firstChild:new d(i),h)};const m=/^(?:plaintext|script|style|textarea|title|xmp)$/i,v=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,x=/<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\/?)>/g,b=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,w=/[\x01\x02]/g;const $=(e,t,n)=>{e.setAttribute(t,n)},N=(e,t)=>{e.removeAttribute(t)},y=()=>j;let C;const A=(t,n,r)=>{r=r.slice(1),C||(C=new WeakMap);const l=C.get(t)||s(C,t,{});let o=l[r];return o&&o[0]&&t.removeEventListener(r,...o),o=e(n)?n:[n,!1],l[r]=o,o[0]&&t.addEventListener(r,...o),n};function W(e,t){const n=this.n||(this.n=e);switch(typeof t){case"string":case"number":case"boolean":n!==e&&n.replaceWith(this.n=e),this.n.data=t;break;case"object":case"undefined":null==t?(this.n=e).data="":this.n=t.valueOf(),n.replaceWith(this.n)}return t}const k=()=>W.bind({n:null}),M=(e,t,n)=>e[n]=t,E=(e,t,n)=>M(e,t,n.slice(1)),S=(e,t,n)=>null==t?(N(e,n),t):M(e,t,n),O=(e,t)=>("function"==typeof t?t(e):t.current=e,t),T=(e,t,n)=>(null==t?N(e,n):$(e,n,t),t),B=(e,t,n)=>(e.toggleAttribute(n.slice(1),t),t),j=(e,n,s,r)=>n.length?((e,t,n,s,r)=>{const l=n.length;let o=t.length,i=l,c=0,a=0,u=null;for(;c<o||a<i;)if(o===c){const t=i<l?a?s(n[a-1],-0).nextSibling:s(n[i-a],0):r;for(;a<i;)e.insertBefore(s(n[a++],1),t)}else if(i===a)for(;c<o;)u&&u.has(t[c])||e.removeChild(s(t[c],-1)),c++;else if(t[c]===n[a])c++,a++;else if(t[o-1]===n[i-1])o--,i--;else if(t[c]===n[i-1]&&n[a]===t[o-1]){const r=s(t[--o],-1).nextSibling;e.insertBefore(s(n[a++],1),s(t[c++],-1).nextSibling),e.insertBefore(s(n[--i],1),r),t[o]=n[i]}else{if(!u){u=new Map;let e=a;for(;e<i;)u.set(n[e],e++)}if(u.has(t[c])){const r=u.get(t[c]);if(a<r&&r<i){let l=c,h=1;for(;++l<o&&l<i&&u.get(t[l])===r+h;)h++;if(h>r-a){const l=s(t[c],0);for(;a<r;)e.insertBefore(s(n[a++],1),l)}else e.replaceChild(s(n[a++],1),s(t[c++],-1))}else c++}else e.removeChild(s(t[c++],-1))}return n})(e.parentNode,r,n,h,e):(r.length&&c(r[0],r.at(-1),!1),t),L=new Map([["aria",(e,t)=>{for(const n in t){const s=t[n],r="role"===n?n:`aria-${n}`;null==s?N(e,r):$(e,r,s)}return t}],["class",(e,t)=>S(e,t,null==t?"class":"className")],["data",(e,t)=>{const{dataset:n}=e;for(const e in t)null==t[e]?delete n[e]:n[e]=t[e];return t}],["ref",O],["style",(e,t)=>null==t?S(e,t,"style"):M(e.style,t,"cssText")]]),z=(e,t,n)=>{switch(t[0]){case".":return E;case"?":return B;case"@":return A;default:return n||"ownerSVGElement"in e?"ref"===t?O:T:L.get(t)||(t in e?t.startsWith("on")?M:S:T)}},F=(e,t)=>(e.textContent=null==t?"":t,t);let R,Z,D=document.createElement("template");var G=(e,t)=>{if(t)return R||(R=document.createElementNS("http://www.w3.org/2000/svg","svg"),Z=n(),Z.selectNodeContents(R)),Z.createContextualFragment(e);D.innerHTML=e;const{content:s}=D;return D=D.cloneNode(!1),s};const H=e=>{const t=[];let n;for(;n=e.parentNode;)t.push(t.indexOf.call(n.childNodes,e)),e=n;return t},P=(n,l,o)=>{const i=G(((e,t,n)=>{let s=0;return e.join("").trim().replace(x,((e,t,s,r)=>`<${t}${s.replace(b,"=$2$1").trimEnd()}${r?n||v.test(t)?" /":`></${t}`:""}>`)).replace(w,(e=>""===e?`\x3c!--${t+s++}--\x3e`:t+s++))})(n,_,o),o),{length:c}=n;let a=!1,u=t;if(c>1){const t=document.createTreeWalker(i,129),n=[];let s=0,h=`${_}${s++}`;for(u=[];s<c;){const i=t.nextNode();if(8===i.nodeType){if(i.data===h){let t=e(l[s-1])?y:k;t===k?n.push(i):a=!0,u.push(r(8,H(i),t)),h=`${_}${s++}`}}else{let e;for(;i.hasAttribute(h);){e||(e=H(i));const t=i.getAttribute(h);u.push(r(2,e,z(i,t,o),t)),N(i,h),h=`${_}${s++}`}m.test(i.localName)&&i.textContent.trim()===`\x3c!--${h}--\x3e`&&(u.push(r(3,e||H(i),F)),h=`${_}${s++}`)}}for(s=0;s<n.length;s++)n[s].replaceWith(document.createTextNode(""))}const h=i.childNodes.length;return s(V,n,((e,t,n)=>({c:e,e:t,l:n}))(i,u,1===h&&a?0:h))},V=new WeakMap,_="isµ";var q=e=>(t,n)=>V.get(t)||P(t,n,e);const I=g(q(!1)),J=g(q(!0)),K=(e,{s:n,t:s,v:r})=>{r.length&&e.s===t&&(e.s=[]);const l=Q(e,r);if(e.t!==s){const{n:t,d:l}=(n?J:I)(s,r);e.t=s,e.n=t,e.d=l}else{const{d:t}=e;for(let e=0;e<l;e++){const n=r[e],s=t[e],{v:l}=s;if(n!==l){const{u:e,t:t,n:r}=s;s.v=e(t,n,r,l)}}}return e.n},Q=({s:n},s)=>{const{length:r}=s;for(let o=0;o<r;o++){const r=s[o];r instanceof U?s[o]=K(n[o]||(n[o]=l(t)),r):e(r)?Q(n[o]||(n[o]=l([])),r):n[o]=null}return r<n.length&&n.splice(r),r};class U{constructor(e,t,n){this.s=e,this.t=t,this.v=n}}
/*! (c) Andrea Giammarchi - MIT */const X=e=>(t,...n)=>new U(e,t,n),Y=X(!1),ee=X(!0),te=new WeakMap;var ne=(e,n)=>{const r=te.get(e)||s(te,e,l(t)),o="function"==typeof n?n():n,{n:i}=r,c=o instanceof U?K(r,o):o;return i!==c&&e.replaceChildren(r.n=c),e};const se=new WeakMap,re=e=>(n,r)=>{const o=se.get(n)||s(se,n,new Map);return o.get(r)||s(o,r,function(t,...n){return K(this,new U(e,t,n))}.bind(l(t)))},le=re(!1),oe=re(!0);export{U as Hole,L as attr,Y as html,le as htmlFor,ne as render,ee as svg,oe as svgFor};