-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-encode view-transition-names #10099
Conversation
🦋 Changeset detectedLatest commit: 1633717 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
const reEncodeInValidStart: string[] = "-0123456789" | ||
.split('').reduce((v, c) => (v[c.charCodeAt(0)] = c, v), [] as string[]); | ||
|
||
function reEncode(s: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comments that explain the re-encoding logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can't understand why I didn't do that from the start ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts on the changeset here, for your consideration @martrapp ! 🙌
I didn't find anything that explains why it's being requested by the browser. |
Co-authored-by: Sarah Rainsberger <[email protected]>
Changes
We have observed regressions with the cssesc view-transition-name encoding as Chrome seems to have issues with some specification-compliant view transition names. Specifically with backslash-escaped, printable ASCII letters like
\.
,\
,\$
but alos\30
which would encode a '0'.We fix this on the Astro side. Closes #10081
Instead of removing all problematic characters or replacing them with
_
(as we did in our original solution), this fix re-encodes them in a way that works for cssesc/Chrome, still supports all Unicode characters > 0x7f, and doesn't create collisions for different inputs.Problematic characters are replaced by their character code. This is somewhat more difficult to read in the generated CSS, but is more robust. For example
Welcome to Astro.
is now encoded asWelcome20_to20_Astro2e_
.Testing
Adapted and extended existing e2e tests
(Which only shows that Chrome accepts the encoding but not whether it acts on them.Did that.We could add animation event listeners to be sure.)
Docs
bug fix, no implication on documentation of transition:name
/cc @withastro/maintainers-docs for feedback on changeset