Skip to content

fix(vue-vapor): guard node.children access#142

Merged
doodlewind merged 1 commit into
pocket-stack:mainfrom
zhiyuanzmj:fix/node-children
Jul 22, 2026
Merged

fix(vue-vapor): guard node.children access#142
doodlewind merged 1 commit into
pocket-stack:mainfrom
zhiyuanzmj:fix/node-children

Conversation

@zhiyuanzmj

Copy link
Copy Markdown
Contributor

When switching tab.value, a null/undefined node will be rendered as a text node, which does not have a children property.

<View class="grow flex-col">
        {tab.value === 0 ? <Overview /> : null}
 </View>
image

Copilot AI review requested due to automatic review settings July 21, 2026 17:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Vue Vapor renderer edge case where switching conditional content can yield a text-node-shaped value that lacks a children property, causing traversal code to throw during retention/sweep checks.

Changes:

  • Adds a guard in subtreeHasRetained() to avoid accessing node.children when it’s missing at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/native-tree.ts
Comment on lines 365 to 373
function subtreeHasRetained(node: NodeMirror): boolean {
if (!node) return false;
if (retained.has(node)) return true;
for (let i = 0; i < node.children.length; i++) {
if (subtreeHasRetained(node.children[i])) return true;
if (node.children) {
for (let i = 0; i < node.children.length; i++) {
if (subtreeHasRetained(node.children[i])) return true;
}
}
return false;
@doodlewind
doodlewind merged commit c3eeaa6 into pocket-stack:main Jul 22, 2026
doodlewind added a commit that referenced this pull request Jul 22, 2026
…port work)

Conflicts were squash-merge echoes of the launcher PR plus the ESP32
viewport refactor: kept the .pocket package side everywhere it owned the
hunk, took main's join()-style paths and SimViewportOptions, and merged
the test chain as the union of both additions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

3 participants