fix(core): keep safeJoin side-effect-free for DOM elements (#21353)#21356
Open
archievi wants to merge 1 commit into
Open
fix(core): keep safeJoin side-effect-free for DOM elements (#21353)#21356archievi wants to merge 1 commit into
archievi wants to merge 1 commit into
Conversation
…#21353) In 10.55.0 safeJoin switched non-primitive serialization from String() to stringifyValue(), which for DOM elements routes through the browser stringifier's htmlTreeAsString and reads id/className/getAttribute, invoking user-defined getters (and walking the DOM) during console breadcrumb capture. Short-circuit elements via String() so breadcrumb serialization stays side-effect free. Adds a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #21353
oxlint) and the affected test suite passes (vitest run packages/core/test/lib/utils/string.test.ts→ 29/29).Summary
In
10.55.0,safeJoin(packages/core/src/utils/string.ts) switched non-primitive serialization fromString(value)tostringifyValue(...). For DOM elements,stringifyValueroutes through the browser stringifier'shtmlTreeAsString, which readsid/className/getAttributeand walks the ancestor chain — so capturing a console breadcrumb now invokes user-defined property getters and traverses the DOM on everyconsole.log(element), even when no event is sent. (<= 10.54.0was side-effect-free viaString(value).)This short-circuits DOM elements in
safeJoinback to a side-effect-freeString(value), while keepingstringifyValuefor other non-primitive values (functions, plain objects, etc.).htmlTreeAsStringis intentionally left intact — it is still used for the click/DOM breadcrumb path that legitimately needs the selector string.Added a regression test asserting
safeJoindoes not invoke getters or the stringifier for elements (it fails on the current code and passes with this change).