This works well when the component does not differentiate the types of children. E.g. "all children are carousel's slides". When children have different designations we can use attributes to assign them different roles. For instance, a customized "next" button in the carousel can be marked up as <button arrow-next>. If these attributes can change after the initialization, we may need to observe each child for attribute changes as well. E.g.
Most of composite elements would want to know their children, which can be easily monitored using mutation observer:
This works well when the component does not differentiate the types of children. E.g. "all children are carousel's slides". When children have different designations we can use attributes to assign them different roles. For instance, a customized "next" button in the carousel can be marked up as
<button arrow-next>
. If these attributes can change after the initialization, we may need to observe each child for attribute changes as well. E.g.The goal is to avoid this as much as possible given the additional performance and code management cost.