Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Sep 11, 2023
1 parent fa77fa6 commit c934b08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions packages/astro/components/ViewTransitions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const { fallback = 'animate' } = Astro.props as Props;
const parser = new DOMParser();

// A noop element used to prevent styles from being removed
if(import.meta.env.DEV) {
if (import.meta.env.DEV) {
var noopEl: string | undefined = document.createElement('div');
}

Expand Down Expand Up @@ -145,13 +145,15 @@ const { fallback = 'animate' } = Astro.props as Props;
}
}
// Only run this in dev. This will get stripped from production builds and is not needed.
if(import.meta.env.DEV) {
if(el.tagName === 'STYLE' && el.dataset.viteDevId) {
if (import.meta.env.DEV) {
if (el.tagName === 'STYLE' && el.dataset.viteDevId) {
const devId = el.dataset.viteDevId;
// If this same style tag exists, remove it from the new page
return doc.querySelector(`style[data-astro-dev-id="${devId}"]`)
// Otherwise, keep it anyways. This is client:only styles.
|| noopEl;
return (
doc.querySelector(`style[data-astro-dev-id="${devId}"]`) ||
// Otherwise, keep it anyways. This is client:only styles.
noopEl
);
}
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/view-transitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ test.describe('View Transitions', () => {
await expect(p, 'should have content').toHaveText('Page 1');
});

test("client:only styles are retained on transition", async ({ page, astro }) => {
test('client:only styles are retained on transition', async ({ page, astro }) => {
const totalExpectedStyles = 8;

// Go to page 1
Expand Down

0 comments on commit c934b08

Please sign in to comment.