-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Interaction with class and style properties #11246
Comments
As said at #11244 (comment), in Vue 2, use a custom prop to retrieve classes and have full control over it.
This is a breaking change and won't happen in Vue 2. Vue 3 already has a solution: vuejs/rfcs#137. It will be appreciated if you could check it and see if it help you and if it doesn't, indicate what would be needed |
To me it seems like youre not even interested in improving the behavior in the current Vue 2.x version. The fix doesn't have to be a breaking change, it could also be a workaround for example. |
The core team are hard at work on v3. I wouldn't expect new features to land on the v2 branch from them as a result. I bet if you were able to find a non-breaking way to implement your feature, they'd be more amenable to considering it as PR. With my limited knowledge of Vue's core though, I don't expect this feature to be possible without introducing backwards compatibility issues. |
@sirlancelot A non-breaking way to implement this feature(s) would be possible. There was also a pretty similar issue in the past: #11132 and there it wasn't immediately closed as in my case. Here are my suggestions:
In this way this wouldn't be a breaking change, because you only introduce new functionality. Maybe also worth a read for @posva |
What problem does this feature solve?
Currently the user isn't able to control the class and style properties of a component.
Example:
As a library author I want that my component has a static class and no style at all.
The component template looks like this:
Someone decided to use this component and does this:
Now the component has two classes
class="the-only-allowed-class class-set-by-user"
because vue does a merge behind the scenes. As a component author I have basically no control over the class (and also the style) property.I can't read the set
class
orstyle
property, I can't prevent them to be set, I can't watch them so that I could somehow act after they were set. I can basically do nothing about it.Thats what this feature request shall solve.
In comparison, libraries like
React
andAngular
have such a feature.What does the proposed API look like?
Don't handle the
class
andstyle
property like something special. Just handle them as normal properties. Make them watchable inside thewatch
object. Make them (somehow) readable with exposing them in the$attrs
object. etc.The text was updated successfully, but these errors were encountered: