-
Notifications
You must be signed in to change notification settings - Fork 395
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
test(integration-karma): add a new FORCED_MIXED_SHADOW_MODE #2496
Conversation
Reading through W-9726385, I thought that the goal was to run LWC in native mode, but in such a way that it wasn't aware of synthetic shadow DOM? It looks like this PR is force-opting components into native mode when synthetic shadow is loaded, but LWC is still aware of synthetic shadow and is just not using it. These two scenarios are both valid to test, but I'm not sure what we were trying to test here. /cc @ekashida Am I misreading this? |
// Forced mixed shadow mode for testing | ||
if (process.env.FORCED_MIXED_SHADOW_MODE) { |
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.
To be extra sure this never makes it into prod, I'd add an additional guard here. Also suggest we make name the name more explicit.
// Forced mixed shadow mode for testing | |
if (process.env.FORCED_MIXED_SHADOW_MODE) { | |
if (process.env.NODE_ENV !== 'production') { | |
if (process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST) { |
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.
I already put it inside a if (process.env.NODE_ENV !== 'production')
(Line 315). I can change the name to be more explicit.
@nolanlawson Sorry, didn't see your comments.
That sounds like a very subtle distinction. Could you explain the difference? |
With # 2, we could run it in our CI, but plenty of the tests would fail because of synthetic shadow bugs. Maybe it's not practical to test for the moment. |
@nolanlawson In mixed shadow mode RFC, it says "A third testing mode will be introduced for mixed shadow mode. This test environment will ensure that components running in native mode will work correctly even when synthetic Shadow DOM polyfills are present." So I think this way it would be the third testing mode. I may be understanding it incorrectly but wouldn't # 1 and # 2 in your comment have same effects? Is "LWC engine acts as if everything is pure native shadow" equivalent to lwc operates in native shadow mode? Or would LWC engine operates differently in native mode when it realizes that synthetic shadow is loaded? |
This makes sense to me! I think this PR is valid; I was just trying to understand what the goal is.
No, because in # 1, LWC understands that synthetic shadow is present. When it wants to render in native mode, it passes in a special lwc/packages/@lwc/engine-core/src/framework/base-lightning-element.ts Lines 243 to 247 in bca4d26
...which synthetic shadow uses to understand that it should call the actual native lwc/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts Lines 79 to 82 in bca4d26
Whereas in # 2, the communication link between synthetic shadow and engine-dom is broken. So LWC believes it's operating on top of native shadow, but in fact it's operating on top of synthetic shadow. This reveals the kind of bugs that may occur if, for instance, LWC is combined with another shadow-DOM-using framework on the same page, and synthetic shadow DOM is present. |
… be more specific
@nolanlawson Thanks for the detailed explanation! That makes sense. |
Details
Add a "FORCED_MIXED_SHADOW_MODE" to integration-karma so that tests run in native shadow mode while applying synthetic shadow polyfill.
Does this PR introduce breaking changes?
No, it does not introduce breaking changes.
If yes, please describe the impact and migration path for existing applications.
The PR fulfills these requirements:
GUS work item
W-9726385