-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow cssHash value to be null #7095
Comments
I'm not sure if we want |
I feel the same. If anything, this should throw an error if you don't return a string with a length of more than zero. |
We have #6821 for making the compiler throw an error when the return value would result in an invalid class name. We don't want a falsy return value to be a backdoor way into disabling scoping. (Even if it rendered the styles with no scoping class, it wouldn't prevent it from matching selectors against this component and removing unused ones. ) There are other mechanisms for this (like |
|
Describe the problem
Scoped styles in Svelte have been notoriously problematic over the years. The changes introduced in #4377 could in theory have allowed to disable the scoping css class altogether but in the current implementation falsy values are returned as strings – where:
compiled with
cssHash: () => false
returns:and an empty string
cssHash: () => ''
returns:Describe the proposed solution
Better handling of the
cssHash
property should instead remove the class in its entirety, so that for instancecssHash: () => null
would return:Alternatives considered
If the goal is to disable css scoping there's also the possibility of defining the value of
cssHash
to be a unique string and manually remove all instances of it in the html and css code respectively. But it all seems like a tedious workaround for a feature that should have been optional in the first place.Importance
i cannot use svelte without it
The text was updated successfully, but these errors were encountered: