Skip to content

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

Open
JiuqingSong wants to merge 1 commit into
masterfrom
fix-list-node-stack-cleanup
Open

Clear whole list node stack when leaving its root parent#3357
JiuqingSong wants to merge 1 commit 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

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://microsoft.github.io/roosterjs/pr-preview/pr-3357/

Built to branch gh-pages at 2026-05-29 18:38 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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