Skip to content

Clear whole list node stack when leaving its root parent#3357

Merged
JiuqingSong merged 2 commits into
masterfrom
fix-list-node-stack-cleanup
Jun 3, 2026
Merged

Clear whole list node stack when leaving its root parent#3357
JiuqingSong merged 2 commits into
masterfrom
fix-list-node-stack-cleanup

Conversation

@JiuqingSong
Copy link
Copy Markdown
Collaborator

Summary

Fixes an issue where the model-to-DOM list node stack could be incorrectly reused across sibling block groups.

When handleBlockGroupChildren finishes processing a block group whose list node stack is rooted at the parent node being left (nodeStack[0].node === parent), the whole node stack is now cleared instead of only its inner levels. This prevents a subsequent sibling block group from reusing the now-invalidated list element.

Changes

  • cleanUpNodeStack now takes an optional leavingParent argument. When it is the root of the node stack, the entire stack is popped.
  • handleBlockGroupChildren passes the parent node as leavingParent in the end-of-loop cleanup.

Tests

Added two unit tests to handleBlockGroupChildrenTest.ts:

  • Verifies the whole node stack is cleared when leaving a parent that is the root of the node stack.
  • Verifies the node stack root is preserved when leaving a different parent.

Both pass; the new behavior test fails against the previous code, confirming it guards the fix.

Original bug

https://outlookweb.visualstudio.com/Outlook%20Web/_workitems/edit/422204

🤖 Generated with Claude Code

When handleBlockGroupChildren finishes processing a block group whose list node stack is rooted at the parent being left, clear the entire node stack instead of only its inner levels so a sibling block group does not incorrectly reuse the invalidated list element.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-03 16:37 UTC

@JiuqingSong JiuqingSong merged commit b43bd45 into master Jun 3, 2026
8 checks passed
@JiuqingSong JiuqingSong deleted the fix-list-node-stack-cleanup branch June 3, 2026 16:37
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.

2 participants