Skip to content
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

Merged
merged 13 commits into from
Feb 14, 2024
Merged

Re-encode view-transition-names #10099

merged 13 commits into from
Feb 14, 2024

Conversation

martrapp
Copy link
Member

@martrapp martrapp commented Feb 13, 2024

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 as Welcome20_to20_Astro2e_.

Testing

Adapted and extended existing e2e tests
(Which only shows that Chrome accepts the encoding but not whether it acts on them.
We could add animation event listeners to be sure.)
Did that.

Docs

bug fix, no implication on documentation of transition:name
/cc @withastro/maintainers-docs for feedback on changeset

Copy link

changeset-bot bot commented Feb 13, 2024

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release labels Feb 13, 2024
Copy link
Contributor

@github-actions github-actions bot left a 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.

@martrapp martrapp changed the title re-encode view-transition-names Re-encode view-transition-names Feb 13, 2024
.changeset/many-lobsters-accept.md Show resolved Hide resolved
const reEncodeInValidStart: string[] = "-0123456789"
.split('').reduce((v, c) => (v[c.charCodeAt(0)] = c, v), [] as string[]);

function reEncode(s: string) {
Copy link
Member

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?

Copy link
Member Author

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 ;-)

@ematipico ematipico added this to the 4.4 milestone Feb 13, 2024
@martrapp
Copy link
Member Author

Hi @lilnasy, How far have you got with your cssesc investigation? (#10006 / #9880)

Copy link
Member

@sarah11918 sarah11918 left a 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 ! 🙌

.changeset/many-lobsters-accept.md Outdated Show resolved Hide resolved
.changeset/many-lobsters-accept.md Outdated Show resolved Hide resolved
@lilnasy
Copy link
Contributor

lilnasy commented Feb 13, 2024

I didn't find anything that explains why it's being requested by the browser.

@martrapp martrapp marked this pull request as draft February 14, 2024 10:55
@martrapp martrapp marked this pull request as ready for review February 14, 2024 13:16
@ematipico ematipico merged commit b340f8f into main Feb 14, 2024
13 checks passed
@ematipico ematipico deleted the mt/cssesc branch February 14, 2024 14:07
@astrobot-houston astrobot-houston mentioned this pull request Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transition:name no longer works with special characters after the introduction of cssesc
5 participants