-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathes.js
1 lines (1 loc) · 2.15 KB
/
es.js
1
self.JSDON=function(e){"use strict";const{parse:t}=JSON,s=e=>{const t=e.length-1,s=e[t];"number"==typeof s&&s<0?e[t]+=-1:e.push(-1)},a=({name:e,value:t},s)=>{s.push(2,e),t&&s.push(t)},r=(e,t,n,c)=>{if(n(e)){const{nodeType:o}=e;switch(o){case 1:(({attributes:e,childNodes:t,localName:n},c,o)=>{c.push(1,n);for(let t=0,{length:s}=e;t<s;t++)a(e[t],c);for(let e=0,{length:s}=t;e<s;e++)r(t[e],c,o);s(c)})(e,t,n);break;case 3:case 8:t.push(o,e.data);break;case 11:case 9:t.push(o),(({childNodes:e},t,a)=>{for(let s=0,{length:n}=e;s<n;s++)r(e[s],t,a);s(t)})(e,t,n);break;case 10:{const{name:s,publicId:a,systemId:r}=e;t.push(o,s),a&&t.push(a),r&&t.push(r);break}default:t.push(42,c(e))}}},n=()=>!0;return e.fromJSON=(e,s=document,a=Object)=>{const r="string"==typeof e?t(e):e,{length:n}=r,c=s.createDocumentFragment();let o=c,l=!1,h=s,i=!0,m=0;for(;m<n;){let e=r[m++];switch(e){case 1:const t=r[m++],n=t.toLowerCase(),p=[];let u=0,d="";for(;2===r[m];){const e=r[++m],t="string"==typeof r[m+1]?r[++m]:"";"is"===e&&(d=t),u=p.push({name:e,value:t}),m++}(i||n!==o.localName.toLowerCase())&&(o=o.appendChild("svg"===n||"ownerSVGElement"in o?h.createElementNS("http://www.w3.org/2000/svg",t):d?h.createElement(t,{is:d}):h.createElement(t)));for(let e=0;e<u;e++)o.setAttribute(p[e].name,p[e].value);i=!0;break;case 3:o.appendChild(h.createTextNode(r[m++]));break;case 8:o.appendChild(h.createComment(r[m++]));break;case 9:const g=new s.defaultView.DOMParser;if(10===r[m]){m++;const e=r[m++],t=[e];for(;"string"==typeof r[m];)t.push(`"${r[m++]}"`);switch(t.length){case 2:t[1]=`${/\.dtd"$/i.test(t[1])?"SYSTEM":"PUBLIC"} ${t[1]}`;break;case 3:t[1]=`PUBLIC ${t[1]}`}switch(e){case"html":case"HTML":h=g.parseFromString(`<!DOCTYPE ${t.join(" ")}><html></html>`,"text/html");break;case"svg":case"SVG":h=g.parseFromString(`<!DOCTYPE ${t.join(" ")}><svg />`,"image/svg+xml");break;default:h=g.parseFromString("<root />","text/xml")}}else h=g.parseFromString("<html></html>","text/html");o=h.documentElement,i=!1;break;case 11:l=!0;break;case 42:o.appendChild(a(r[m++]));break;default:do{e-=-1,o=o.parentNode||c}while(e<0)}}return l?c:h!==s?h:c.firstChild},e.toJSON=(e,t,s=Object)=>{const a=[];return r(e,a,t||n,s),a},e}({});