-
-
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
Analyse ternary expressions when detecting unused CSS #696
Comments
What if the class is computed by a compute function? |
In some cases we could do it: export default {
computed: {
buttonClass(active) {
return active ? 'active' : 'inactive';
}
}
}; It would require a bit more machinery, but we can determine that the return value of In some cases it would be much harder: import buttonClass from './buttonClass.js';
export default {
computed: {
buttonClass(active) {
return buttonClass(active);
}
}
}; The same goes for helper functions. Inline expressions are definitely easier though. |
optimise for ternary expressions when excluding unused css
Inline expressions are now handled. Have left computed/helper equivalents at least for the time being |
In 1.24, Svelte will warn on unused selectors, but cases like this result in a false negative:
It's actually not very hard to determine that the button has two possible classes —
active
andinactive
— and optimise accordingly.The text was updated successfully, but these errors were encountered: