Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(platform-browser): correctly add external stylesheets to ShadowDOM components #58482

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

Closed
wants to merge 1 commit into from

Conversation

clydin
Copy link
Member

@clydin clydin commented Nov 2, 2024

Angular components that use ShadowDOM view encapsulation have an alternate execution path for adding component styles to the DOM that does not use the SharedStylesHost that all other view encapsulation modes leverage. To ensure that ShadowDOM components receive all defined styles, additional logic has been added to the ShadowDOM specific renderer to also cover external styles. In the future, it may be useful to review the DOM renderers and shared styles host to potentially remove the near duplicate ShadowDOM style logic.

@clydin clydin added the target: rc This PR is targeted for the next release-candidate label Nov 2, 2024
@crisbeto
Copy link
Member

crisbeto commented Nov 3, 2024

I think is solving more or less the same issue as #42112 which got stuck in limbo.

@clydin clydin force-pushed the external-styles-shadow-dom branch from 562d8e9 to 2d49cb0 Compare November 3, 2024 17:45
@clydin clydin requested a review from AndrewKushnir November 3, 2024 17:51
@clydin clydin marked this pull request as ready for review November 3, 2024 17:52
@clydin
Copy link
Member Author

clydin commented Nov 3, 2024

A more comprehensive review of the style handling is something we should definitely consider in the future.
This change at least unblocks stylesheet hot replacement with shadow DOM components for v19.

@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 3, 2024
@pkozlowski-opensource pkozlowski-opensource added the area: core Issues related to the framework runtime label Nov 3, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 3, 2024
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, just a minor comment 👍

@crisbeto could you please also review this change when you get a chance?

…M components

Angular components that use ShadowDOM view encapsulation have an alternate
execution path for adding component styles to the DOM that does not use the
SharedStylesHost that all other view encapsulation modes leverage. To ensure
that ShadowDOM components receive all defined styles, additional logic has been
added to the ShadowDOM specific renderer to also cover external styles.
@clydin clydin force-pushed the external-styles-shadow-dom branch from 2d49cb0 to 5f132c5 Compare November 4, 2024 15:00
@angular-robot angular-robot bot removed the area: core Issues related to the framework runtime label Nov 4, 2024
@ngbot ngbot bot removed this from the Backlog milestone Nov 4, 2024
@pkozlowski-opensource pkozlowski-opensource added the area: core Issues related to the framework runtime label Nov 4, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 4, 2024
@clydin clydin 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 Nov 4, 2024
@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit c22b5ac.

The changes were merged into the following branches: main, 19.0.x

pkozlowski-opensource pushed a commit that referenced this pull request Nov 5, 2024
…M components (#58482)

Angular components that use ShadowDOM view encapsulation have an alternate
execution path for adding component styles to the DOM that does not use the
SharedStylesHost that all other view encapsulation modes leverage. To ensure
that ShadowDOM components receive all defined styles, additional logic has been
added to the ShadowDOM specific renderer to also cover external styles.

PR Close #58482
@clydin clydin deleted the external-styles-shadow-dom branch November 5, 2024 13:50
@lincolnthree
Copy link
Contributor

As a user who has struggled with some Shadow DOM/Style interactions in the past, I'm encouraged to see this. Could someone explain the practical implications of this change, and how one might interact with it in their Angular code?

Thanks for your work!

@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 Dec 21, 2024
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: core Issues related to the framework runtime target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants