UNPKG

@qwik.dev/core

Version:

An open source framework for building instant loading web apps at any scale, without the extra effort.

6 lines (5 loc) 2.75 kB
const QWIK_BACKPATCH_EXECUTOR_MINIFIED = "const t='script[type=\"qwik/backpatch\"]';function e(e,n){const o=n||e.querySelector(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");if(o){const n=o.querySelectorAll(t),r=n[n.length-1];if(r){const t=JSON.parse(r.textContent||\"[]\"),n=e.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let c=n.currentNode,i=c.hasAttribute(\":\")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],r=t[e+1];let l=t[e+2];for(;i<o&&(c=n.nextNode(),c);)c.hasAttribute(\":\")&&i++;const s=c;null==l||!1===l?s.removeAttribute(r):(\"boolean\"==typeof l&&(l=\"\"),s.setAttribute(r,l))}}}}const n=document.currentScript;if(n){const t=n.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");t&&e(document,t)}"; const QWIK_BACKPATCH_EXECUTOR_DEBUG = "const BACKPATCH_DATA_SELECTOR = 'script[type=\"qwik/backpatch\"]';\nfunction executeBackpatch(doc, containerElement) {\n const container = containerElement || doc.querySelector(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");\n if (container) {\n const scripts = container.querySelectorAll(BACKPATCH_DATA_SELECTOR);\n const script = scripts[scripts.length - 1];\n if (script) {\n const data = JSON.parse(script.textContent || \"[]\");\n const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);\n let currentNode = walker.currentNode;\n let currentNodeIdx = currentNode.hasAttribute(\":\") ? 0 : -1;\n for (let i = 0; i < data.length; i += 3) {\n const elementIdx = data[i];\n const attrName = data[i + 1];\n let value = data[i + 2];\n while (currentNodeIdx < elementIdx) {\n currentNode = walker.nextNode();\n if (!currentNode) {\n break;\n }\n if (currentNode.hasAttribute(\":\")) {\n currentNodeIdx++;\n }\n }\n const element = currentNode;\n if (value == null || value === false) {\n element.removeAttribute(attrName);\n } else {\n if (typeof value === \"boolean\") {\n value = \"\";\n }\n element.setAttribute(attrName, value);\n }\n }\n }\n }\n}\nconst executorScript = document.currentScript;\nif (executorScript) {\n const container = executorScript.closest(\n \"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"\n );\n if (container) {\n executeBackpatch(document, container);\n }\n}"; globalThis.QWIK_BACKPATCH_EXECUTOR_MINIFIED = QWIK_BACKPATCH_EXECUTOR_MINIFIED; globalThis.QWIK_BACKPATCH_EXECUTOR_DEBUG = QWIK_BACKPATCH_EXECUTOR_DEBUG; export { QWIK_BACKPATCH_EXECUTOR_MINIFIED, QWIK_BACKPATCH_EXECUTOR_DEBUG };