ampproject / ampproject/amp-react-prototype

Children attribute mutations

Open
#53 0 comments 0 reactions 0 assignees View on GitHub
TBD
Dominant language
JavaScript
Stars
36
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Most of composite elements would want to know their children, which can be easily monitored using mutation observer:

```
mutationObserver.observe(this.element, {childList: true});
```

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 ``. If these attributes can change after the initialization, we may need to observe each child for attribute changes as well. E.g.

```
mutationObserver.observe(child, {attributes: true, attributesFilter: ...});
```

The goal is to avoid this as much as possible given the additional performance and code management cost.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.