ampproject / ampproject/amp-react-prototype

Slot delegation

Open
#42 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

Consider a carousel button customization. There are two approaches to place it in carousel:
1. Clone it as a vDOM component. This has a problem of losing styles, external event handlers, and an expected DOM hierarchy.
2. Slot it. The problem is that `disabled` attribute (Web spec issue) and event handlers (React issue) do not propagate from the `slot` to the distributed button.

As a result we created the [implementation](https://github.com/ampproject/amp-react-prototype/blob/c4c7373542f30feda4a1b539db1781f88bdc5063/src/react-compat-base-element.js#L605) where we propagate state and events from the slot to button and back manually.

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.