@lifeart/gxt
Version:
<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">
2 lines (1 loc) • 10.4 kB
JavaScript
function e(e){if("text"===e)return Y[Y.length-1];if("node"===e){const e=K.get(M()+"");if(e){const t=Y.indexOf(e);return t>-1&&(Y.splice(t,1),Y.push(e)),e}}else if("comment"===e){const e=M(),t=Z.find(t=>t.nodeType===Node.COMMENT_NODE&&t.textContent?.includes(`$[${e}]`));if(t)return Y.push(t),Z.splice(Z.indexOf(t),1),t;console.warn(`Unable to find comment node with id: ${e}.`)}return Y[Y.length-1]}function t(){const e=Y.pop();return e&&(e.nodeType,Node.COMMENT_NODE),e}function n(e,t=!1){e.dataset.nodeId&&(K.set(e.dataset.nodeId,e),e.removeAttribute("data-node-id"));const o=e.shadowRoot?e.shadowRoot.childNodes:e.childNodes;t||Y.push(e);const r=o.length;1===o.length&&(o[0].nodeType,Node.TEXT_NODE);for(let i=r-1;i>=0;i--){const e=o[i];e.nodeType!==Node.TEXT_NODE?e.nodeType===Node.COMMENT_NODE?Z.push(e):n(e):z.add(e)}}function o(e,t,o,r=B()){const i=new W(document),a=[{api:i,namespace:void 0}],d={factory:e=>{let t;return t=e===x?new q(document):e===w?new J(document):new W(document),a.push({api:t,namespace:e}),t}};try{if(b(!0),n(o,!0),v(),S(),$(r,R,i),$(r,A,d),z.forEach(e=>{const t=document.createComment("[text-placeholder]");e.parentElement?e.parentElement.replaceChild(t,e):e.remove()}),X(e,{args:t,element:o,owner:r}),Y.length>0){const e=Array.from(Y);if(console.warn("withRehydrationStack is not empty",e),Y.length=0,e.filter(e=>e.parentElement&&e.isConnected).length)throw Error("withRehydrationStack is not empty and node is connected");e.forEach(e=>{e.isConnected&&e.remove()})}b(!1),K.clear();for(const{api:e,namespace:t}of a){let n;n=t===x?U.prototype:t===w?L.prototype:P.prototype,Object.getOwnPropertyNames(n).forEach(t=>{"constructor"!==t&&(e[t]=n[t])})}}catch(s){throw b(!1),Y.length=0,K.clear(),H(r),v(),s}}function r(e){te=e}function i(){return te}function a(){ee=null}function d(e){ee=e}function s(){return ee}async function c(){const e=[];G.forEach((t,n)=>{null===t&&e.push(n)});const t=e.map(e=>j.get(e));for(const n of t)await Promise.all(H(n));v(),a()}function l(e,t={}){o(e,t,N())}async function u(e){v();let t=B();d(t);const n=await async function(e,t,n){const o=n.document.createElement("div");X(e,{args:{},element:o,owner:n});const r=o.innerHTML;return o.remove(),r}(e,0,t);N().innerHTML=n,await Promise.all(H(t)),v(),a()}function N(){return i().getElementById("ember-testing")}function m(e,t){const n=`${QUnit.config.current.moduleName}::${QUnit.config.current.testName}`;class o extends y{[Q]=[];constructor(){super(...arguments),this.debugName=n}template(n){return V(t,this),F([I(e,{...n},this)],this)}}return o.prototype.toString=()=>n,o}async function p(e){S();const t=i().getElementById("ember-testing");await c(),t.childNodes.length&&(console.warn("testing container not empty, force cleanup"),console.info(t.innerHTML),t.innerHTML="");const n=B();d(n);let o=X(m(e,n),{element:t,owner:n});return await E(),o}async function E(e=16){await new Promise(t=>{let n=!1;k(()=>{n||(n=!0,t())}),setTimeout(()=>{n||(n=!0,t())},e)}),await new Promise(e=>setTimeout(e,0))}function f(e){return i().getElementById("ember-testing").querySelector(e)}function T(e){return i().getElementById("ember-testing").querySelectorAll(e)}async function h(e){const t=f(e);if(!t)throw Error("Unable to find DOM element matching selector: "+e);const n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});t.dispatchEvent(n),await E()}function g(e){QUnit.assert.pushResult({message:"[Step] "+e,result:!0,expected:!0,actual:!0})}import{C as y}from"./component-class-DA1pm8lP.js";import{a7 as C,T as O,Q as M,a8 as x,a9 as D,aa as _,ab as w,ac as b,Z as v,M as S,W as $,R,ad as A,Y as X,ae as U,af as L,J as P,a0 as H,N as B,u as F,m as I}from"./dom-BiflCx2O.js";import{P as G,T as j,H as k,R as Q,I as V}from"./vm-CFZXVoe9.js";class W{constructor(e){this.doc=e}isNode(e){return"nodeType"in e}parent(e){return e.parentElement}destroy(e){e.remove()}clearChildren(e){e.innerHTML=""}toString(){return"hydration-html:dom-api"}addEventListener(e,t,n){if(e.addEventListener(t,n),RUN_EVENT_DESTRUCTORS_FOR_SCOPED_NODES)return()=>{e.removeEventListener(t,n)}}prop(e,t,n){return C()&&e[t]===n||(e[t]=n),n}attr(e,t,n){C()&&e.getAttribute(t)===n||e.setAttribute(t,null===n?"":n)}comment(n=""){if(O(),C()){const n=e("comment");if(void 0!==n&&n.nodeType===Node.COMMENT_NODE){const e=t();if(e&&e.nodeType===Node.COMMENT_NODE)return e;throw Error(`Rehydration failed. Expected tagName: ${e} got: ${e?.tagName}.`)}}return this.doc.createComment(`${n} $[${M()}]`)}text(n=""){const o=n+"";if(C()){const n=e("text");if(n&&n.nodeType===Node.TEXT_NODE){const e=t();if(e&&e.nodeType===Node.TEXT_NODE)return e.textContent!==o&&(e.textContent=o),e;throw Error(`Rehydration failed. Expected textContent, got: ${e?.tagName}.`)}}return this.doc.createTextNode(o)}textContent(e,t){C()&&e.textContent===t||(e.textContent=t)}fragment(){return this.doc.createDocumentFragment()}element(n=""){if(C()){let o=e("node");if(o&&o.nodeType===Node.COMMENT_NODE)return t(),this.element(n);if(o&&o.nodeType===Node.TEXT_NODE){const e=t();return e&&e.remove(),this.element(n)}let r=t();if(!r||r.tagName!==n.toUpperCase()&&r.tagName!==n){if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE)){if(r=t(),r&&r.tagName===n.toUpperCase())return r;if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE))return this.element(n);throw Error(`Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}throw Error(`Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}return r}return this.doc.createElement(n)}insert(e,t,n){if(!t.isConnected){if(e&&t.nodeType===Node.TEXT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){const n=Array.from(e.childNodes).filter(e=>e.nodeType===Node.COMMENT_NODE&&(e.data+"").includes("[text-placeholder]"));if(n.length>0)return void e.replaceChild(t,n[0])}if(e!==t){if(C()){const r=n?n.previousSibling:e.lastChild;if((n?n.nextSibling:e.firstChild)===t)return;if(r===t)return;if(r&&r.nodeType===Node.TEXT_NODE&&r.textContent===t.textContent)return void e.replaceChild(t,r);if(e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(r&&r.nodeType===Node.COMMENT_NODE&&t.nodeType===Node.COMMENT_NODE&&r.textContent===t.textContent){try{r.remove()}catch(o){console.error(o,{child:t,existingChild:r,childParent:t.parentElement,existingChildParent:r.parentElement})}return}if(r&&r.nodeType===Node.COMMENT_NODE&&t.nodeType===Node.COMMENT_NODE);else if(null!==r){if(t.isConnected)return;if(t.nodeType!==Node.TEXT_NODE)if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){if(0!==t.childElementCount)throw Error(`Rehydration failed. Expected child: ${t} got: ${r}.`)}else if(t.nodeType===Node.COMMENT_NODE);else{if(t.nodeName!==r.nodeName)throw Error(`Rehydration failed. Expected child: ${t} got: ${r}.`);e.replaceChild(t,r)}}}else if(t.isConnected)return}C()&&n&&n.nodeType===Node.TEXT_NODE&&t.nodeType===Node.TEXT_NODE?n.textContent===t.textContent&&e.replaceChild(t,n):e.insertBefore(t,n||null)}}}}class q{constructor(e){this.doc=e}isNode(e){return"nodeType"in e}destroy(e){e&&e.remove()}clearChildren(e){e.innerHTML=""}parent(e){return e.parentNode}comment(e=""){return this.doc.createComment(e)}fragment(){return this.doc.createDocumentFragment()}addEventListener(e,t,n){}toString(){return"hydration-svg:dom-api"}text(e){return this.doc.createTextNode(e+"")}textContent(e,t){C()&&e.textContent===t||(e.textContent=t)}element(n){if(C()){let o=e("node");if(o&&o.nodeType===Node.COMMENT_NODE)return t(),this.element(n);if(o&&o.nodeType===Node.TEXT_NODE){const e=t();return e&&e.remove(),this.element(n)}let r=t();if(!r||r.tagName!==n.toUpperCase()&&r.tagName!==n){if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE)){if(r=t(),!r||r.tagName!==n.toUpperCase()&&r.tagName!==n){if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE))return this.element(n);throw Error(`SVG Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}return r}throw Error(`SVG Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}return r}return this.doc.createElementNS(x,n)}attr(e,t,n){C()&&e.getAttribute(t)===n||(t.includes(":")?t.startsWith("xmlns")?e.setAttributeNS(D,t,n):t.startsWith("xlink")?e.setAttributeNS(_,t,n):e.setAttributeNS(x,t,n):e.setAttribute(t,n))}prop(e,t,n){if(C())if("className"===t){if(e.getAttribute("class")===n)return n}else if(e.getAttribute(t)===n)return n;return"className"===t?e.setAttribute("class",n):e.setAttribute(t,n),n}insert(e,t,n){if(!t.isConnected){if(C()){const o=n?n.previousSibling:e.lastChild;if((n?n.nextSibling:e.firstChild)===t)return;if(o===t)return}e.insertBefore(t,n||null)}}}class J{constructor(e){this.doc=e}isNode(e){return"nodeType"in e}destroy(e){e&&e.remove()}clearChildren(e){e.innerHTML=""}parent(e){return e.parentNode}comment(e=""){return this.doc.createComment(e)}fragment(){return this.doc.createDocumentFragment()}addEventListener(e,t,n){}toString(){return"hydration-mathml:dom-api"}text(e){return this.doc.createTextNode(e+"")}textContent(e,t){C()&&e.textContent===t||(e.textContent=t)}element(n){if(C()){let o=e("node");if(o&&o.nodeType===Node.COMMENT_NODE)return t(),this.element(n);if(o&&o.nodeType===Node.TEXT_NODE){const e=t();return e&&e.remove(),this.element(n)}let r=t();if(!r||r.tagName!==n.toUpperCase()&&r.tagName!==n){if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE)){if(r=t(),!r||r.tagName!==n.toUpperCase()&&r.tagName!==n){if(r&&(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE))return this.element(n);throw Error(`MathML Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}return r}throw Error(`MathML Rehydration failed. Expected tagName: ${n} got: ${r?.tagName}.`)}return r}return this.doc.createElementNS(w,n)}attr(e,t,n){C()&&e.getAttribute(t)===n||(t.includes(":")?e.setAttributeNS(w,t,n):e.setAttribute(t,n))}prop(e,t,n){return C()&&e.getAttribute(t)===n||e.setAttribute(t,n),n}insert(e,t,n){if(!t.isConnected){if(C()){const o=n?n.previousSibling:e.lastChild;if((n?n.nextSibling:e.firstChild)===t)return;if(o===t)return}e.insertBefore(t,n||null)}}}const Y=[],Z=[],z=/* @__PURE__ */new Set,K=/* @__PURE__ */new Map;let ee=null,te="undefined"!=typeof document?document:void 0;export{c as cleanupRender,h as click,m as createTestComponent,f as find,T as findAll,i as getDocument,s as getRoot,l as rehydrate,p as render,N as renderTarget,E as rerender,a as resetRoot,r as setDocument,d as setRoot,u as ssr,g as step};