Support adding/removing from element metadata array
When extending existing element it is sometimes desirable to just add or remove an item from an array.
Consider the following <my-component>
component wrapping an <input>
element and dynamically binding all attributes from the component:
<input type="text" :attrs="attrs">
Suitable element metadata would be:
{
"my-component": {
"inherit": "input"
}
}
Since <input>
requires type
to be set ("requiredAttributes": ["type"]
) usage of <my-component>
would yield errors despite the underlying <input>
element having the type
attribute.
Setting requiredAttributes
to an empty array would reset the attribute but possibly remove other unwanted attributes from the array. It would be useful to have a method of removing elements from the array without resetting it.
Suggested solution
Support setting This would have issues with non-string types and if the item has an actual leading requiredAttributes
to ["-type"]
to remove type
when merging the array without removing other entries. Similarly a +
could be used to add entries.+
or -
, i.e. consider an attribute such as tabindex="-1"
.
Perhaps the array could be specified with an object structure similar to:
"requiredAttributes": {
"add": ["foo"],
"remove": ["bar"]
}