The following rules exists for modifers in components:
- All unused attributes are applied to the root element
- Attributes override existing attributes on the root element
- It's possible to 'merge' attributes with the following syntax:
class="existing-class-name {{ class }}"
It works but is not very explicit. We should support some modifiers both when defining attributes inside components and when using components.
Inside component definitions:
<div :class="existing-class-name" !id="my-component">
</div>
The : modifier makes the attribute 'mergable'. That means the class attribute will automatically get merged with any classes passed in when using the component.
The ! modifier makes the attribute 'non-overridable'. If passing in an 'id' it will cause a compilation error unless the attribute is explicitly used somewhere else in the component definition.
When using components it's also possible to use the ! modifier. This will make it so the attributes overrides an attribute in the definition markes as mergable
The following rules exists for modifers in components:
class="existing-class-name {{ class }}"It works but is not very explicit. We should support some modifiers both when defining attributes inside components and when using components.
Inside component definitions:
The
:modifier makes the attribute 'mergable'. That means theclassattribute will automatically get merged with any classes passed in when using the component.The
!modifier makes the attribute 'non-overridable'. If passing in an 'id' it will cause a compilation error unless the attribute is explicitly used somewhere else in the component definition.When using components it's also possible to use the
!modifier. This will make it so the attributes overrides an attribute in the definition markes asmergable