ampproject / ampproject/amp-react-prototype
Slot delegation
- Vorherrschende Sprache
- JavaScript
- Sterne
- 36
- Forks
- 6
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Start with src/react-compat-base-element.js around line 605, the linked implementation of slot state and event propagation. Review the two approaches described in the issue, focusing on disabled attributes, event handlers, styles, and DOM hierarchy. The issue does not define a preferred approach or explicit completion criteria, so clarify the desired behavior before changing code.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- frontend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100