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

Enable :root selector for native-shadow-only CSS #4832

Closed
nolanlawson opened this issue Nov 11, 2024 · 1 comment · Fixed by #4833
Closed

Enable :root selector for native-shadow-only CSS #4832

nolanlawson opened this issue Nov 11, 2024 · 1 comment · Fixed by #4833
Labels
enhancement Up for grabs Issues that are relatively small, self-contained, and ready for implementation

Comments

@nolanlawson
Copy link
Contributor

nolanlawson commented Nov 11, 2024

Originally we disallowed using the :root selector because it doesn't work in synthetic shadow DOM. Trying to use it in CSS results in the error:

Error: CssSyntaxError: LWC1009: /.../x/app/app.css:1:1: Invalid usage of unsupported selector ":root".

Now that we have disableSyntheticShadowSupport, though, we could conceivably relax this rule for CSS that only targets native shadow DOM. Or we could have the selector somehow throw an error at runtime only when rendered in synthetic shadow DOM. Edit: nah, let's just rely on disableSyntheticShadowSupport.

@nolanlawson nolanlawson added enhancement Up for grabs Issues that are relatively small, self-contained, and ready for implementation labels Nov 11, 2024
@nolanlawson
Copy link
Contributor Author

Marking as "up for grabs." Steps to implement:

First, only throw this error if disableSyntheticShadowSupport is false:

// Ensure the selector doesn't use an unsupported selector.
if (UNSUPPORTED_SELECTORS.has(value)) {
throw root.error(`Invalid usage of unsupported selector "${value}".`, {
index: sourceIndex,
word: value,
});
}

Then pipe in disableSyntheticShadowSupport to this function as necessary.

Then add a test in the fixtures with the flag enabled to ensure that :root and :host-context() both work (the latter is Chromium-only, but no need for us to block it if you are targeting native shadow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Up for grabs Issues that are relatively small, self-contained, and ready for implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant