fix(csr,ui): deliver component outputs to parent bindings
An output only reaches a parent @binding when the component calls output.<name>(). Two separate faults meant most of the library never got there, and both failed silently at each end. HTML lowercases attribute names, so a parent's @sizeChange registered under "sizechange" while the component emitted "sizeChange". The lookup missed, fell through to a DOM dispatch, and the binding was never invoked. That made all 17 camelCase outputs undeliverable -- DataTable.pageChange and .rowClick, Map.markerClick, ChatBubble.messageClick, LayoutSplitter.sizeChange and the rest. invokeComponentOutput now falls back to a case-insensitive lookup, and a csr test fails without it. Separately, 18 components dispatched hand-built CustomEvents rather than calling output.*. A bubbling event on the component's own root never reaches a binding, because parent handlers live in a registry only the output proxy reads. Card, Footer, Breadcrumb, Accordion, alert, Badge, AnnouncementBar, AvatarGroup, ToggleCount and InputNumber now emit properly; Marquee, Map, Timeline, List and SearchBox additionally declare the outputs they were already firing. Dispatches on window are left alone -- that is how Toaster, Modal and DataTable signal across component boundaries. Verified in a browser both ways before and after: an AnnouncementBar dispatching its own bubbling "dismiss" never reached a page-level @dismiss, and reached it immediately once it called output.dismiss(). This corrects the audit, which called the LayoutSplitter failure "narrow and unexplained" and read 32 dead outputs as 16 components needing a rebuild. "Outputs work elsewhere" was an assumption; the components that worked happened to use lowercase names and output.*. The dead-output ratchet drops from 32 to 22, and a new test forbids the raw-CustomEvent pattern outright. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,30 +29,58 @@ Two mistakes worth recording, because both nearly became wrong conclusions:
|
||||
- The semantic token spread sat _after_ the primary and secondary palette
|
||||
entries, so it would have overridden them. It now sits before.
|
||||
|
||||
## Correction: outputs, and what was actually wrong
|
||||
|
||||
The first version of this audit called the LayoutSplitter output failure
|
||||
"narrow and unexplained" and treated 32 dead outputs as 16 components needing a
|
||||
rebuild. Both were wrong, and the real cause was found by binding a page
|
||||
handler to a component in a browser and watching what arrived.
|
||||
|
||||
**Two distinct faults were hiding behind one symptom.**
|
||||
|
||||
_Emitting the wrong way._ An output only reaches a parent `@binding` when the
|
||||
component calls `output.<name>()`. The runtime resolves parent handlers from a
|
||||
registry that only `invokeComponentOutput` reads, so a component that builds
|
||||
its own `CustomEvent` — even a bubbling one, dispatched on its own root —
|
||||
emits into nothing. Eighteen components did exactly that, so their outputs were
|
||||
declared, documented, apparently fired, and never delivered. Converting them
|
||||
took ten dead outputs off the list and cost no new machinery.
|
||||
|
||||
_Case._ HTML lowercases attribute names, so a parent's `@sizeChange` registers
|
||||
under `sizechange` while the component emits `sizeChange`. The lookup missed,
|
||||
fell through to a DOM dispatch, and the binding was never invoked — silently,
|
||||
with no error at either end. **All 17 camelCase outputs in the library were
|
||||
undeliverable**, including `DataTable.pageChange` and `DataTable.rowClick`,
|
||||
`Map.markerClick`, `ChatBubble.messageClick` and `LayoutSplitter.sizeChange`.
|
||||
The runtime now falls back to a case-insensitive lookup, and a test in
|
||||
`packages/csr` fails without that fallback.
|
||||
|
||||
The lesson worth keeping: "outputs work elsewhere" was an assumption, not a
|
||||
measurement. The components that worked happened to use all-lowercase names and
|
||||
`output.*`; that coincidence made a framework-wide bug look like one broken
|
||||
component.
|
||||
|
||||
## Outstanding, with numbers
|
||||
|
||||
**32 outputs across 16 components have no emitter of any kind.** This is the
|
||||
bug LayoutSplitter had: the component advertises an output, a caller binds to
|
||||
it, and nothing ever fires. Native event names are excluded — the runtime binds
|
||||
a DOM-listener fallback on component tags, so `click` and `input` do arrive.
|
||||
**22 outputs across 11 components have no emitter of any kind** (was 32 across
|
||||
16; see the correction above). The component advertises an output, a caller
|
||||
binds to it, and nothing ever fires. Native event names are excluded — the
|
||||
runtime binds a DOM-listener fallback on component tags, so `click` and `input`
|
||||
do arrive.
|
||||
|
||||
| Component | Dead outputs |
|
||||
| ------------------------------------ | ----------------------------------------- |
|
||||
| FileUpload | upload, progress, success, cancel, remove |
|
||||
| ToastNotifications | add, dismiss, clear, action |
|
||||
| AdvancedDatePicker | open, close, clear |
|
||||
| Card | action, navigate, dismiss |
|
||||
| Accordion | open, close |
|
||||
| AdvancedRangeSlider | start, end |
|
||||
| Chart | dataPointClick, legendToggle |
|
||||
| Confetti | start, complete |
|
||||
| TreeView | expand, collapse |
|
||||
| AnnouncementBar, Badge, Toast, alert | dismiss |
|
||||
| AvatarGroup | overflow |
|
||||
| CopyMarkup | success |
|
||||
| Footer | action |
|
||||
| Component | Dead outputs |
|
||||
| ------------------- | ----------------------------------------- |
|
||||
| FileUpload | upload, progress, success, cancel, remove |
|
||||
| ToastNotifications | add, dismiss, clear, action |
|
||||
| AdvancedDatePicker | open, close, clear |
|
||||
| AdvancedRangeSlider | start, end |
|
||||
| Chart | dataPointClick, legendToggle |
|
||||
| Confetti | start, complete |
|
||||
| TreeView | expand, collapse |
|
||||
| Toast | dismiss |
|
||||
| CopyMarkup | success |
|
||||
|
||||
A test pins this at 32 as a ceiling that only moves down.
|
||||
A test pins this at 22 as a ceiling that only moves down.
|
||||
|
||||
**23 components are still on the `wire-next` scaffold pattern** — no style
|
||||
block, no functions, and for 19 of them an outputs block they never honour.
|
||||
@@ -81,11 +109,6 @@ the busiest activity in the library.
|
||||
|
||||
## Known framework defects
|
||||
|
||||
- **A component output is not delivered to a parent binding in at least one
|
||||
case.** LayoutSplitter emits `sizeChange` and the component genuinely fires
|
||||
the event, but `@sizeChange` on the tag is not invoked. Outputs work
|
||||
elsewhere, so this is narrow and unexplained. Renaming away from the native
|
||||
`resize` did not fix it, so the first hypothesis was wrong.
|
||||
- **A component tag nested inside another component slot is dropped**, leaving
|
||||
only its children.
|
||||
- **Component props and slot content render once** and do not track page state,
|
||||
|
||||
Reference in New Issue
Block a user