Tram-One/tram-lite

Support multiple attributes for a single controlled element

Closed this issue · 2 comments

Summary

For many inputs, there may be multiple attributes that we'd like to control via host attributes. Sadly though, the current interface for tl-controlled only allows a single attribute on the target element.

Examples could include wanting to read:

  • disabled and value of a text input
  • indeterminate and checked of a checkbox input

One way we could solve this would be having an attrmap, that maps element attributes to host attributes. E.g.

<input tl-controlled
       tl-attrmap="disabled:disabled value:value" />

The syntax here would be "<element-attribute-name>:<host-attribute-name>", and could support a space delimited list

It is possible that the above interface would be a breaking change, since users can technically set attributes with : in them (see https://codepen.io/JRJurman/pen/poGoOJK).