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

fix(compiler): incorrectly encapsulating selectors with escape sequences #40264

Closed

Conversation

crisbeto
Copy link
Member

CSS supports escaping in selectors, e.g. writing .foo:bar will match an element with the foo class and bar pseudo-class, but .foo\:bar will match the foo:bar class. Our shimmed shadow DOM encapsulation always assumes that : means a pseudo selector which breaks a selector like .foo\:bar.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes #31844.

@google-cla google-cla bot added the cla: yes label Dec 25, 2020
@crisbeto crisbeto marked this pull request as ready for review December 25, 2020 08:38
@pullapprove pullapprove bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 25, 2020
@ngbot ngbot bot added this to the Backlog milestone Dec 25, 2020
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release type: bug/fix and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Dec 25, 2020
@ngbot ngbot bot modified the milestone: Backlog Dec 25, 2020
@pullapprove pullapprove bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 25, 2020
@ngbot ngbot bot added this to the Backlog milestone Dec 25, 2020
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix @crisbeto 👍

packages/compiler/src/shadow_css.ts Outdated Show resolved Hide resolved
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Jan 6, 2021
CSS supports escaping in selectors, e.g. writing `.foo:bar` will match an element with the
`foo` class and `bar` pseudo-class, but `.foo\:bar` will match the `foo:bar` class. Our
shimmed shadow DOM encapsulation always assumes that `:` means a pseudo selector
which breaks a selector like `.foo\:bar`.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes angular#31844.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 6, 2021
@crisbeto crisbeto force-pushed the 31844-encapsulation-escape-characters branch from 053232c to 79c12bb Compare January 6, 2021 06:05
@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Jan 6, 2021
josephperrott pushed a commit that referenced this pull request Jan 6, 2021
…ces (#40264)

CSS supports escaping in selectors, e.g. writing `.foo:bar` will match an element with the
`foo` class and `bar` pseudo-class, but `.foo\:bar` will match the `foo:bar` class. Our
shimmed shadow DOM encapsulation always assumes that `:` means a pseudo selector
which breaks a selector like `.foo\:bar`.

These changes add some extra logic so that escaped characters in selectors are preserved.

Fixes #31844.

PR Close #40264
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler cla: yes target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS encapsulation breaks classes with escaped : colon in name
2 participants