When designing components that wrap native components, there are a lot of attributes that the end-developer would want to apply to the underlying native element. For example, take <button>. It's common to wrap <button> in a component in order to manipulate its appearance or add animation, while still using a native button underneath. When doing this, all of the HTML spec attributes, such as form, formAction, formMethod, etc, should still work as expected.
It would be super fantastic for component authors to have some easy way to pass/copy through this type of attribute without having to manually creating a binding for each one. Some types of elements can have quite a few of these attributes (<button> has 11). Most of the time, attributes like this are completely static, and thus using data binding for them feels like overkill.
Element types where I think this would apply are <button>, <input>, <textarea>, <video>, and <audio>. These are all things that someone could conceivably want to wrap in a custom component that passes through the static attributes.
There are also some global attributes where passing through static attributes would be useful, such as class and tabindex.
Additionally, passing through event bindings would also keep down boilerplate when wrapping these kinds of components (especially media events for <audio> and <video>).
There could be more use-cases I'm not considering, but since the set of elements seems limited, this could be something that's scoped specifically to these elements. For example, something like:
@Component({
attributeCopyBehavior: 'button'
})
When designing components that wrap native components, there are a lot of attributes that the end-developer would want to apply to the underlying native element. For example, take
<button>. It's common to wrap<button>in a component in order to manipulate its appearance or add animation, while still using a native button underneath. When doing this, all of the HTML spec attributes, such asform,formAction,formMethod, etc, should still work as expected.It would be super fantastic for component authors to have some easy way to pass/copy through this type of attribute without having to manually creating a binding for each one. Some types of elements can have quite a few of these attributes (
<button>has 11). Most of the time, attributes like this are completely static, and thus using data binding for them feels like overkill.Element types where I think this would apply are
<button>,<input>,<textarea>,<video>, and<audio>. These are all things that someone could conceivably want to wrap in a custom component that passes through the static attributes.There are also some global attributes where passing through static attributes would be useful, such as class and tabindex.
Additionally, passing through event bindings would also keep down boilerplate when wrapping these kinds of components (especially media events for
<audio>and<video>).There could be more use-cases I'm not considering, but since the set of elements seems limited, this could be something that's scoped specifically to these elements. For example, something like: