Skip to content

vapor_split: locate elements by DOM node position (0.16.1) - #7

Merged
dannote merged 2 commits into
mainfrom
fix-split-text-siblings
Oct 3, 2026
Merged

dannote merged 2 commits into
mainfrom
fix-split-text-siblings

Conversation

@dannote

@dannote dannote commented Oct 3, 2026

Copy link
Copy Markdown
Member

For vize 0.16.1.

The bug

vapor_split silently dropped slots when a text node came before an element:

Vize.vapor_split!(~S|<ul><li>a<ul><li>{{ b }}</li></ul></li><li>c</li></ul>|)
# before: statics ["<ul><li>a<ul><li> </li></ul></li><li>c</li></ul>"], slots []
# after:  statics ["<ul><li>a<ul><li>", "</li></ul></li><li>c</li></ul>"], slots [%{kind: :set_text, ...}]

Vize's IR is correct. It navigates with child_ref/next_ref offsets that count every DOM child node, including text runs and <!----> anchors, so the inner ul is offset 1 inside its li, after the text a. The split's tag mapping counted element children only, so it found no element at that offset and skipped the slot without an error. A text-only fallback hid the problem in some simpler templates.

The fix

  • The template scanner records each tag's DOM node index, counting text runs and anchors, and child_ref/next_ref resolve by it. The element-only child_index is removed.
  • If an element that a text, HTML or prop slot, an event, v-model or v-show belongs to still can't be located, vapor_split returns {:error, [message]} instead of dropping the slot.

Found while checking Vue 3.6.0-rc.10's compiler-vapor fixes against Vize. Those fixes are upstream Vize's to port; this bug was in vize_ex's own split code.

This also carries a docs-only commit linking Vue's documentation for Vapor mode, SFCs and SSR.

Verification

  • VIZE_EX_BUILD=1 mix ci passes: lint (including clippy) and 125 tests.
  • Regression tests cover:
    • the nested-list case;
    • mixed text and elements with text, prop and later text slots;
    • an event binding after a text node.
  • A Rust unit test covers node indices across text runs and anchors.
  • Templates with tables, SVG foreignObject, interleaved text and v-for options all place every slot and binding.

Vapor's child and next references count every DOM child node, text runs
and anchors included, but the split's tag mapping counted element
children only. After a text node it looked for the wrong element, found
none, and silently skipped the slot: in
<li>a<ul><li>{{ b }}</li></ul></li> the interpolation disappeared.

Record each tag's node index while scanning the template and resolve
references with it. If an element still can't be located, return an
error instead of dropping its slot or binding.
@dannote
dannote merged commit d5ebe7d into main Oct 3, 2026
2 checks passed
@dannote
dannote deleted the fix-split-text-siblings branch October 3, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant