-
Notifications
You must be signed in to change notification settings - Fork 26.5k
feat(platform-browser): Add IsolatedShadowDom encapsulation #62723
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
feat(platform-browser): Add IsolatedShadowDom encapsulation #62723
Conversation
@thePunderWoman - Hey 👋 This is the new PR as we discussed in #62357 where i've taken the approach of migrating anyone on the existing shadowdom onto a new I have manually tested running the migration locally, seems to work! One thing i am not 100% on though, as I predominantly use Thanks! |
As is, this is considered a breaking change as the This probably needs to be discussed if the best is to keep ShadowDom as is (would reduce the burden of landing the change) and introduce a new symbol for the new behavior. |
I'll mark as breaking 👍 Yeah the other option i mentioned was just creating a new encapsulation mode with the "fixed" shadowdom But I leaned towards this as any new apps/components spun up would get the fixed behaviour, and it was suggested in the other PR it would be a lot of work for the team/users to change everything if you landed just the fixed version. By marking it as deprecated users would at least be nudged in the right direction, and hopefully make the Angular teams job a bit easier in the future 🤞 Otherwise we're just kicking the can down the road and you'll have two sets of encapsulations for shadowdom (arguably confusing), more to maintain, and in theory more components to fix later down the line when you pick it up from your backlog |
Regarding priority of this PR: I was recently exploring using shadow DOM to isolate styles across multiple applications within the same page (MicA). One challenge is that Regarding this PR more specifically: I wonder if this setting should be configured via dependency injection rather than creating a new A token does potentially make it a bit harder to incrementally roll out this change, but I suspect it's not that breaking and maybe doesn't need to have a super fine-grained opt-out? You could certainly use DI to opt-out specific components, though the hierarchy is kind of working against you there since opting-out one component naturally opts-out its dependencies, which isn't really what you want. I'm mainly just asking whether this is worth a new |
@ryan-bendel Looks like this needs a few goldens updated. |
@thePunderWoman ohhh I didn't know about that step, thanks! Pushed that now |
I'll look at the failing tests, will run the same command locally the action is using. Not 100% clear on what is needed in some targets, for example, Side note, i've never once been able to run the test_firefox tests without it falling over 😆 |
Grrr. I might need a bit of help with this if one of the Angular team wouldn't mind jumping on my branch?
I can't work out what is going on here, this build file is identical in all but name to the Really struggling to run the full test suite locally because it can't seem to locate the Firefox bin and bombs out. Just doing a build of the core package passes, so i've no clue what's going on 😢 |
e0f927a
to
966bc88
Compare
@ryan-bendel Looks like there were some recent change with these bazel rules. |
@thePunderWoman you're a star ⭐ - I think i tried that in a previous commit, and may have ended up failing elsewhere so i reverted, lets see how it goes this time 🤞 |
Ah yes:
Which confused me, as it's the same import path as other migrations. I'd lost the will to live at this point 😆 |
@ryan-bendel looks like it did get past that problem, but now has ✨other✨ problems. I can take a look. |
The Similar confusion with the overrides, i.e Thank you for your help! Much appreciated |
966bc88
to
dad506a
Compare
@ryan-bendel Bazel can be confusing. I figured out what needed to be in the deps for it to build. |
843b581
to
2c67757
Compare
Pushed the test fixes and changes requested, will squash commits when the build is green |
cf88059
to
bdbd6e8
Compare
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.
No concerns on my end, thanks for the contribution here!
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.
LGTM! Super huge thanks, @ryan-bendel, for your effort here! 🎉
reviewed-for: fw-compiler, fw-general, angular-dev, public-api
@ryan-bendel you have a tiny docs conflict. Once you resolve that, this should be merge ready!!! |
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.
reviewed-for: public-api
IsolatedShadowDom encapsulation fixes style leakage in Shadowdom encapsulation by removing sharedstyleshost from dom-renderer IsolatedShadowdom class. Updates docs.
bdbd6e8
to
d616425
Compare
@thePunderWoman merge resolved 😃 - thanks everyone for this |
This PR was merged into the repository by commit d24d574. The changes were merged into the following branches: main |
oh this is a great feature that we desperately need |
Add IsolatedShadowDom encapsulation mode, which fixes style leakage by removing sharedstyleshost from dom-renderer IsolatedShadowDom class.
PR Checklist
Please check if your PR fulfills the following requirements:
Does this PR introduce a breaking change?
IsolatedShadowDom follows the spec, shadowdom does not now add
<style>
tags unrelated/not imported/defined by the component, which is caused by thesharedstyleshost
.Updated docs.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: 57801
Follow up to the PR discussion in #62357
The current Shadowdom implementation is incorrect, and does not adhere to the spec. Shadowdom components should be encapsulated with no style leakage, but currently, external styles are added that are completely unrelated to the shadow component. This causes significant bloat.
Before:
After:
What is the new behavior?
To ensure this is a smooth transition for users, the old behaviour has been preserved in a the ShadowDom encapsulation class.
IsolatedShadowDom
has been created to allow users to implement the fixed shadowdom behaviour, which does not use sharedstyleshost.