Skip to content

Commit

Permalink
Move VT route announcer styles to a class (#8965)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored Oct 31, 2023
1 parent ef8964c commit 430c470
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/sweet-nails-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': patch
---

Move VT route announcer styles to a class

Doing so allows stricter CSP policies.
13 changes: 13 additions & 0 deletions packages/astro/components/viewtransitions.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@
animation: none !important;
}
}

/* Route announcer */
.astro-route-announcer {
position:absolute;
left:0;
top:0;
clip:rect(0 0 0 0);
clip-path:inset(50%);
overflow:hidden;
white-space:nowrap;
width:1px;
height:1px;
}
5 changes: 1 addition & 4 deletions packages/astro/src/transitions/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const announce = () => {
let div = document.createElement('div');
div.setAttribute('aria-live', 'assertive');
div.setAttribute('aria-atomic', 'true');
div.setAttribute(
'style',
'position:absolute;left:0;top:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap;width:1px;height:1px'
);
div.className = 'astro-route-announcer';
document.body.append(div);
setTimeout(
() => {
Expand Down

0 comments on commit 430c470

Please sign in to comment.