Skip to content

Keep visitor suppression balanced with optional callbacks - #159

Open
Pradeep Ramola (pradeep-ramola) wants to merge 1 commit into
microsoft:mainfrom
pradeep-ramola:fix/optional-visitor-suppression
Open

Pradeep Ramola (pradeep-ramola) wants to merge 1 commit into
microsoft:mainfrom
pradeep-ramola:fix/optional-visitor-suppression

Conversation

@pradeep-ramola

Copy link
Copy Markdown

Fixes #158.

Subtree suppression currently only updates its depth when the corresponding user-supplied begin/end callback exists. This makes optional callback combinations either suppress later siblings indefinitely or expose events from inside a skipped subtree.

Always update suppression depth at object/array boundaries, independently of whether the user supplied a handler. Continue to invoke only installed handlers. A supplied matching end handler for the skipped container still runs, preserving the behavior introduced in #88.

Added 16 callback-combination tests covering skipped objects and arrays, omitted opposite-type begin handlers, omitted object/array end handlers, nested mixed containers, sibling values and paths, property callbacks, comments, separators, and matching end events.

Validation on Windows:

  • Before the fix: 12 new cases fail and four controls pass.
  • npm test with Node 22.23.5: TypeScript compilation, ESLint, and all 104 tests pass.
  • Full compiled suite with Node 24.16.0: all 104 tests pass.
  • 14,848 additional event-trace comparisons pass across all 512 optional-callback subsets, nested stop locations, comments, malformed JSON, and incomplete input. Each sparse visitor is compared with the corresponding filtered trace from a fully installed visitor.
  • git diff --check: passes.

No public API or dependency changes. Based directly on main, without #155 or #157. Linux and macOS were not tested locally.

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.

Optional visitor callbacks break subtree suppression and sibling traversal

1 participant