There are many cases where attributes passed to a Vue component should not be added to the root element, but rather a sub-element. For example, in this UI component, an incredible amount of props must be used to ensure that attributes are added to the input
element, instead of the wrapper div
.
Additionally, it's often desirable to expose all event listeners on a form element to the parent, which also requires a lot of boilerplate currently if the element is not the root (in which case, the .native
modifier can solve the problem).
EDIT: Start here to catch up on the discussion.
Currently by default, the "exposed" element (the one that arbitrary attributes can be added to) is always the root element. A new directive could be used to define a different exposed element. Some ideas for the name of the directive:
v-expose
(probably my personal favorite)v-expose-attrs
(probably clearer, but lengthier)v-main
v-primary
If v-expose
is added to an element, it will accept attributes passed to its component - and these attributes will no longer be passed to the root element.
Other features that may be nice:
v-expose
could accept a string or array of strings (e.g. v-expose="class"
or v-expose="['class', 'type', 'placeholder']"
). In this case, these attributes would be added to the element (again, instead of to the root element), but all other attributes would be added to the root element or to the element(s) with a valueless v-expose
.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4