Commit e99c33a
committed
fix(core): 6 browser failures fixed, all 26 browser tests pass
Four real bugs surfaced in the browser test suite and are fixed:
1. captureAuthoredChildren ran on every connectedCallback, including
on re-connection of a previously-mounted element. The second
capture wrongly hoovered up the host's existing rendered template
(the marker comments + the <div> with its slot) into the
assignment table, then the re-render's clientRender no-op'd
because INSTANCE was cached. Result: blank slot, lost projection.
Fix: skip capture and adoption when hasSlotState(this) is already
true (re-connection path). State preserved through disconnect by
detachSlotObservers (only the observers pause).
2. adoptSSRAssignments ran AFTER _performRender, but
_performRender's clientRender calls createInstance which calls
replaceChildren and wipes the SSR-placed children before adoption
ever sees them. Fix: move adoptSSRAssignments to BEFORE
_performRender so the assignment table holds Node references to
the SSR-placed children. createInstance still wipes them from the
host, but they remain alive via the state map, and projection
re-attaches them to the freshly-cloned slot. DOM identity is
preserved through the hydration round-trip.
3. Child slot=" " attribute changes were observed only with
subtree:false, so children already projected into slot elements
(which sit one level deeper than the host) became invisible to
the observer. Fix: subtree:true on the MutationObserver, with
defensive checks in the callback. childList handler still filters
to node.parentElement === host so projection's own
slot.appendChild deep in the tree does not re-fire the capture
path. removedNodes still skips when host.contains(node) so
projection moves into a slot are not mistaken for user removals.
4. The slot-part apply hook only ran inside createInstance, never
inside applyChild's nested-template branch. A <slot> inside
`${cond ? html\`<slot/>\` : ''}` is part of an inner template
compiled and bound separately when the outer's child-position
hole resolves; its parts never saw the slot-apply tail loop. Fix:
add the same slot-apply tail loop after the nested-template's
insertBefore so the slot's microtask retry fires and projection
runs. Conditional collapse + re-expansion now preserves projected
child Node identity through the pending-fragment hand-off.
Also: applyFallback no longer pushes children to the pending map.
That code was a leftover from the conditional-collapse design; the
correct path for that case lives in moveSlotChildrenToPending
(called from clearInstance). applyFallback's push was an unrelated
correctness hazard for user-initiated child removals.
The slot-part apply now retries on the next microtask when
findSlotHost returns null at first (the slot is still inside an
unattached fragment for nested templates). The retry fires after the
outer's replaceChildren, at which point parent-walk reaches the host.
Tests pass:
26 of 26 browser cases in test/browser/slot.test.js
51 of 51 unit cases in test/component-slot.test.js
178 server-side unit cases across the broader sweep
(component, render-client, render-server, directives, registry,
css, html, context, task, suspense, repeat, testing,
blog-smoke, json-negotiation, light-dom-ssr)
Remaining for Task 14:
- e2e tests covering SSR + page/layout + client router (per
user's most recent direction)
- Convention check rule (Task 15)1 parent 95d2d37 commit e99c33a
3 files changed
Lines changed: 82 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 392 | + | |
395 | 393 | | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
403 | 416 | | |
| 417 | + | |
404 | 418 | | |
405 | 419 | | |
406 | 420 | | |
| |||
418 | 432 | | |
419 | 433 | | |
420 | 434 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
426 | 441 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | 442 | | |
432 | 443 | | |
433 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
606 | 614 | | |
607 | 615 | | |
608 | | - | |
609 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
610 | 625 | | |
611 | 626 | | |
612 | 627 | | |
| |||
710 | 725 | | |
711 | 726 | | |
712 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
713 | 736 | | |
714 | 737 | | |
715 | 738 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
419 | 426 | | |
420 | 427 | | |
421 | 428 | | |
422 | 429 | | |
423 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
424 | 438 | | |
425 | 439 | | |
426 | 440 | | |
427 | 441 | | |
428 | | - | |
| 442 | + | |
429 | 443 | | |
430 | 444 | | |
431 | 445 | | |
| |||
686 | 700 | | |
687 | 701 | | |
688 | 702 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
694 | 709 | | |
695 | 710 | | |
696 | 711 | | |
| |||
0 commit comments