diff options
Diffstat (limited to 'packages/integrations/lit')
-rw-r--r-- | packages/integrations/lit/client-shim.js | 10 | ||||
-rw-r--r-- | packages/integrations/lit/client-shim.min.js | 16 | ||||
-rw-r--r-- | packages/integrations/lit/src/index.ts | 12 |
3 files changed, 30 insertions, 8 deletions
diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js index cab3fe4d9..e9cf1aecf 100644 --- a/packages/integrations/lit/client-shim.js +++ b/packages/integrations/lit/client-shim.js @@ -1,9 +1,15 @@ async function polyfill() { - const { hydrateShadowRoots } = await import('@webcomponents/template-shadowroot/template-shadowroot.js'); + const { hydrateShadowRoots } = await import( + '@webcomponents/template-shadowroot/template-shadowroot.js' + ); hydrateShadowRoots(document.body); } -const polyfillCheckEl = new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', { includeShadowRoots: true }).querySelector('p'); +const polyfillCheckEl = new DOMParser() + .parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', { + includeShadowRoots: true, + }) + .querySelector('p'); if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) { polyfill(); diff --git a/packages/integrations/lit/client-shim.min.js b/packages/integrations/lit/client-shim.min.js index 0c6a452d8..f9fe14fdd 100644 --- a/packages/integrations/lit/client-shim.min.js +++ b/packages/integrations/lit/client-shim.min.js @@ -8,7 +8,8 @@ var b = (t, n) => { function s() { if (d === void 0) { let t = document.createElement('div'); - (t.innerHTML = '<div><template shadowroot="open"></template></div>'), (d = !!t.firstElementChild.shadowRoot); + (t.innerHTML = '<div><template shadowroot="open"></template></div>'), + (d = !!t.firstElementChild.shadowRoot); } return d; } @@ -18,7 +19,9 @@ var p, c, f, u = i(() => { - (p = (t) => t.parentElement === null), (c = (t) => t.tagName === 'TEMPLATE'), (f = (t) => t.nodeType === Node.ELEMENT_NODE); + (p = (t) => t.parentElement === null), + (c = (t) => t.tagName === 'TEMPLATE'), + (f = (t) => t.nodeType === Node.ELEMENT_NODE); }); var h, E = i(() => { @@ -52,7 +55,8 @@ var h, (e = r), o !== void 0 && o.parentElement.removeChild(o); break; } - let l = (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling; + let l = + (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling; if (l != null) { (e = l), o !== void 0 && o.parentElement.removeChild(o); break; @@ -75,5 +79,9 @@ async function g() { let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v)); t(document.body); } -var x = new DOMParser().parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', { includeShadowRoots: !0 }).querySelector('p'); +var x = new DOMParser() + .parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', { + includeShadowRoots: !0, + }) + .querySelector('p'); (!x || !x.shadowRoot) && g(); diff --git a/packages/integrations/lit/src/index.ts b/packages/integrations/lit/src/index.ts index bf256eb84..f945f1ca3 100644 --- a/packages/integrations/lit/src/index.ts +++ b/packages/integrations/lit/src/index.ts @@ -13,7 +13,12 @@ function getViteConfiguration() { exclude: ['@astrojs/lit/server.js'], }, ssr: { - external: ['lit-element/lit-element.js', '@lit-labs/ssr/lib/install-global-dom-shim.js', '@lit-labs/ssr/lib/render-lit-html.js', '@lit-labs/ssr/lib/lit-element-renderer.js'], + external: [ + 'lit-element/lit-element.js', + '@lit-labs/ssr/lib/install-global-dom-shim.js', + '@lit-labs/ssr/lib/render-lit-html.js', + '@lit-labs/ssr/lib/lit-element-renderer.js', + ], }, }; } @@ -24,7 +29,10 @@ export default function (): AstroIntegration { hooks: { 'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => { // Inject the necessary polyfills on every page (inlined for speed). - injectScript('head-inline', readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' })); + injectScript( + 'head-inline', + readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' }) + ); // Inject the hydration code, before a component is hydrated. injectScript('before-hydration', `import '@astrojs/lit/hydration-support.js';`); // Add the lit renderer so that Astro can understand lit components. |