I am looking for resources on how to make web components that can take positional child arguments. Sort of:
<x-editable-component> <span>{{value}}</span> // this could be any uneditable element <textarea>{{value}}</textarea> //could be any editable element </x-editable-component>
The above element will display the interval when it is editable == false and the text field when edited == true. editable is a static variable observed around the world.
I think one could get similar behavior with inheritance. However, I was wondering if this could be done in the compositional style described above. If the component (x-editable-component) just expects two children, one child will be displayed during editing, the other child will be displayed when it is not selected.
To be clear, I want to flexibly write any two children as x-editable-component children, so maybe somewhere else below. I have an x-editable component written as such.
<x-editable-component> <div>{{value}}</div> // this could be any uneditable element <input>{{value}}</input> //could be any editable element </x-editable-component>
Is it possible?
source share