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

@lwc/synthetic-shadow installed even when native Shadow DOM is available #93

Closed
aputinski opened this issue Jul 2, 2020 · 3 comments · Fixed by #122
Closed

@lwc/synthetic-shadow installed even when native Shadow DOM is available #93

aputinski opened this issue Jul 2, 2020 · 3 comments · Fixed by #122

Comments

@aputinski
Copy link

aputinski commented Jul 2, 2020

Looks like this check is returning undefined even when native Shadow DOM is available (JSDOM 16).

https://github.com/salesforce/lwc-test/blob/master/packages/%40lwc/jest-preset/src/setup.js#L9

I'm guessing $constructorCache$ was changed at some point in JSDOM.

Our LWC components are used with native Shadow DOM, so we have a few tests that check things like assignedNodes()

@pmdartus
Copy link
Member

pmdartus commented Jul 3, 2020

Shadow DOM has been introduced in jsdom 2 years ago with the 12.2 release. JSDOM 16.0 adds support for custom elements. So far synthetic shadow was always enabled regardless if native shadow DOM was supported on not by jsdom. Based on this, I don't think the $constructorCache$ is linked to your issue.

@aputinski Could you please share a minimal repro of your issue for us to investigate further?

Note: As of jsdom 16, the DOM constructors and prototypes are recreated from scratch. This $constructorCache$ is not needed anymore.

@aputinski
Copy link
Author

So far synthetic shadow was always enabled regardless if native shadow DOM was supported on not by jsdom.

@lwc/synthetic-shadow seems to be conditionally required based on that check?

Here's the test case:
https://github.com/aputinski/lwc-jest-preset-test-case

@pmdartus
Copy link
Member

pmdartus commented Jul 6, 2020

I gave a look into this specific issue and I understand better the source of this issue. @lwc/jest-preset always enables the synthetic shadow today to match what is currently experience in Lightning. Currently, LWC component using the synthetic shadow doesn't support slotting for the top-level component. This is why assignedNodes() doesn't return the right result in the test.

IMO, we should add a config flag to turn off synthetic shadow in the case where it is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants