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): strip scoped selectors from @font-face rules #41815

Closed

Conversation

petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Apr 26, 2021

@font-face rules cannot contain nested selectors. Nor can they be
nested under a selector. Normally this would be a syntax error by the
author of the styles. But in some rare cases, such as importing styles
from a library, and applying :host ::ng-deep to the imported styles,
we can end up with broken css if the imported styles happen to contain
@font-face rules.

This commit works around this problem by sanitizing such cases (erasing
any scoping selectors) during emulated ShadowDOM encapsulation style
processing.

Fixes #41751

@google-cla google-cla bot added the cla: yes label Apr 26, 2021
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer core: CSS encapsulation target: patch This PR is targeted for the next patch release labels Apr 26, 2021
@jessicajaniuk jessicajaniuk added the area: compiler Issues related to `ngc`, Angular's template compiler label Apr 26, 2021
@ngbot ngbot bot added this to the Backlog milestone Apr 26, 2021
@petebacondarwin petebacondarwin added the action: presubmit The PR is in need of a google3 presubmit label Apr 26, 2021
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.

@petebacondarwin thanks for the fix 👍

I really like the PR description and I'm wondering if we can move some of that content (or actually all of it) to the _stripScopingSelectors function docs as an additional context for future maintenance?

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 26, 2021
@AndrewKushnir
Copy link
Contributor

Presubmit.

@petebacondarwin
Copy link
Member Author

Added the comment. Marking for merge, pending the outcome of the presubmit.

`@font-face` rules cannot contain nested selectors. Nor can they be
nested under a selector. Normally this would be a syntax error by the
author of the styles. But in some rare cases, such as importing styles
from a library, and applying `:host ::ng-deep` to the imported styles,
we can end up with broken css if the imported styles happen to contain
`@font-face` rules.

This commit works around this problem by sanitizing such cases (erasing
any scoping selectors) during emulated ShadowDOM encapsulation style
processing.

Fixes angular#41751
@petebacondarwin petebacondarwin added the action: merge The PR is ready for merge by the caretaker label Apr 26, 2021
@jessicajaniuk
Copy link
Contributor

Presubmit

@jessicajaniuk jessicajaniuk removed the action: presubmit The PR is in need of a google3 presubmit label Apr 26, 2021
jessicajaniuk pushed a commit that referenced this pull request Apr 27, 2021
`@font-face` rules cannot contain nested selectors. Nor can they be
nested under a selector. Normally this would be a syntax error by the
author of the styles. But in some rare cases, such as importing styles
from a library, and applying `:host ::ng-deep` to the imported styles,
we can end up with broken css if the imported styles happen to contain
`@font-face` rules.

This commit works around this problem by sanitizing such cases (erasing
any scoping selectors) during emulated ShadowDOM encapsulation style
processing.

Fixes #41751

PR Close #41815
jessicajaniuk pushed a commit that referenced this pull request Apr 27, 2021
`@font-face` rules cannot contain nested selectors. Nor can they be
nested under a selector. Normally this would be a syntax error by the
author of the styles. But in some rare cases, such as importing styles
from a library, and applying `:host ::ng-deep` to the imported styles,
we can end up with broken css if the imported styles happen to contain
`@font-face` rules.

This commit works around this problem by sanitizing such cases (erasing
any scoping selectors) during emulated ShadowDOM encapsulation style
processing.

Fixes #41751

PR Close #41815
@petebacondarwin petebacondarwin deleted the ng-deep-issue-41751 branch April 27, 2021 18:02
@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 May 28, 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 core: CSS encapsulation target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:host + ::ng-deep + @font-face produces wrong css
3 participants