mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
now possibly obsolete part for issue 9953
This commit is contained in:
parent
8f37cf72cb
commit
5a8bdeabee
5 changed files with 28 additions and 1 deletions
5
.changeset/tidy-buttons-end.md
Normal file
5
.changeset/tidy-buttons-end.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Adds handling of declarative shadow DOMs during view transitions for browsers that support them via `includeShadowRoots`.
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
import Layout from '../components/Layout.astro';
|
||||
---
|
||||
<Layout>
|
||||
<h2>Shadow DOM</h2>
|
||||
<p id="light"><template shadowroot="open" shadowrootmode="open">Hey there!</template></p>
|
||||
</Layout>
|
|
@ -12,6 +12,7 @@ import Layout from '../components/Layout.astro';
|
|||
<a id="click-redirect-two" href="/redirect-two">go to redirect 2</a>
|
||||
<a id="click-redirect-external" href="/redirect-external">go to a redirect external</a>
|
||||
<a id="click-404" href="/undefined-page">go to undefined page</a>
|
||||
<a id="click-declarative-shadow-dom" href="/declarative-shadow-dom">page with DSD</a>
|
||||
<custom-a id="custom-click-two">
|
||||
<template shadowrootmode="open">
|
||||
<a href="/two">go to 2</a>
|
||||
|
|
|
@ -1351,4 +1351,13 @@ test.describe('View Transitions', () => {
|
|||
'-\\31 1'
|
||||
);
|
||||
});
|
||||
test('automatically handles declarative shadow DOM', async ({ page, astro }) => {
|
||||
await page.goto(astro.resolveUrl('/one'));
|
||||
await page.click('#click-declarative-shadow-dom');
|
||||
const h = page.locator('h2');
|
||||
await expect(h, 'should have content').toHaveText('Shadow DOM');
|
||||
const elementHandle = await page.$('#light');
|
||||
const hasShadowRoot = await page.evaluate((el) => !!el.shadowRoot, elementHandle);
|
||||
expect(hasShadowRoot).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -513,7 +513,12 @@ async function transition(
|
|||
|
||||
parser ??= new DOMParser();
|
||||
|
||||
preparationEvent.newDocument = parser.parseFromString(response.html, response.mediaType);
|
||||
// @ts-ignore includeShadowRoots is only supported in Chrome
|
||||
// @astrojs/lit explicitly requires this because the
|
||||
// polyfill for handling declarative shadow DOMS excludes browsers with native support
|
||||
preparationEvent.newDocument = parser.parseFromString(response.html, response.mediaType, {
|
||||
includeShadowRoots: true,
|
||||
});
|
||||
// The next line might look like a hack,
|
||||
// but it is actually necessary as noscript elements
|
||||
// and their contents are returned as markup by the parser,
|
||||
|
|
Loading…
Reference in a new issue