-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
feat: Support default values for v-bind in CSS #11160
base: main
Are you sure you want to change the base?
Conversation
@@ -103,8 +103,8 @@ describe('CSS vars injection', () => { | |||
const { content } = compileSFCScript( | |||
`<script>const a = 1</script>\n` + | |||
`<style>div{ | |||
color: v-bind(color); | |||
font-size: v-bind('font.size'); | |||
color: v-bind(color, blue); |
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 think it might be better to add new tests for this feature, rather than modifying the existing tests. Otherwise we lose tests for the case where a default isn't provided.
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 have already re-modified and rebased my own branch
There hasn't been an RFC for this change. While I understand that it is a relatively small change, I do worry that we may miss out on feedback from the community without an RFC. I read through the original RFC for
Another comment notes a potential workaround: --myColor: v-bind('myReactiveColor');
color: var(--myColor, black); This does appear to work (Playground) and I believe it would be compatible with pre-processors. As for the implementation in this PR, I worry about backwards compatibility. Commas could already appear in expressions for other reasons, e.g.: Of course the code can be fixed, but I think it illustrates that 'working' code could potentially be broken by this change. |
@skirtles-code |
The default value is defined by an SCSS variable. If the JavaScript variable is null, I want to use the SCSS variable as the fallback.
I don't want to use :export and import in all components
wiill be transfromed to
var(--var-name, $theme-color)
--var-name will be a hashed name, and $theme-color will hold the value assigned to $theme-color.