-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent body scripts from re-executing on navigation (#8603)
* Prevent body scripts from re-executing on navigation * Adding changeset * Run script replacement logic before head * Rename doc to newDocument
- Loading branch information
Showing
6 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Prevent body scripts from re-executing on navigation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/astro/e2e/fixtures/view-transitions/src/components/InlineScript.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div id="counter">Count</div> | ||
<script is:inline> | ||
let count = 1; | ||
const onAfterSwap = () => { | ||
count++; | ||
document.querySelector('#counter').textContent = `Count: ${count}`; | ||
} | ||
document.addEventListener('astro:page-load', onAfterSwap); | ||
</script> |
8 changes: 8 additions & 0 deletions
8
packages/astro/e2e/fixtures/view-transitions/src/pages/inline-script-one.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
import InlineScript from '../components/InlineScript.astro'; | ||
--- | ||
<Layout> | ||
<InlineScript /> | ||
<a id="click-one" href="/inline-script-two">Go to 2</a> | ||
</Layout> |
8 changes: 8 additions & 0 deletions
8
packages/astro/e2e/fixtures/view-transitions/src/pages/inline-script-two.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
import InlineScript from '../components/InlineScript.astro'; | ||
--- | ||
<Layout> | ||
<InlineScript /> | ||
<a id="click-two" href="/inline-script-one">Go to 1</a> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters