Repository navigation
fix(core): align structuredClone, URLSearchParams and Headers with spec - #1865
Merged
Merged
Conversation
- structuredClone(DataView) crashed calling slice() which DataView does
not have; clone the viewed ArrayBuffer and rebuild the view at the
same offset/length per the HTML spec.
- structuredClone silently returned functions, symbols and promises
instead of throwing DataCloneError.
- new URLSearchParams("a#b") treated '#' as a fragment delimiter and
dropped the tail; parse the input as a query string instead of a
relative URL so '#' stays literal.
- new Headers([[1, 2]]) rejected a numeric name; coerce names to
strings like values are.
richarddd
reviewed
Nov 4, 2026
richarddd
requested changes
Nov 4, 2026
richarddd
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! Small comment
Review feedback: fetch the DataView constructor from base primordials instead of looking it up on ctx.globals() per call.
Contributor
Author
|
Done — added constructor_data_view to BasePrimordials and clone.rs now uses it instead of the per-call globals lookup. |
richarddd
approved these changes
Nov 4, 2026
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.
Issue # (if available)
None — found via differential fuzzing of web API behavior against Node.js.
Description of changes
Four small spec-alignment fixes:
structuredClone(DataView)crashed.append_bufferassumed everyArrayBufferview exposesslice();DataViewdoesn't, so cloning any DataView threwTypeError: Error converting from js 'undefined' into type 'function'. The viewedArrayBufferis now cloned and the view rebuilt at the samebyteOffset/byteLength, per the HTML spec.structuredClonesilently returned un-clonable values. Functions, symbols and promises were passed through instead of throwing; they now throwDataCloneError("Value could not be cloned").URLSearchParamstreated#as a fragment delimiter.new URLSearchParams("2éC&Y#C6yR")dropped#C6yRbecause the input was parsed by joining it as a relative URL. The input is now parsed as a query string viaset_query, so#stays a literal — matching the spec's query parsing.Headerstuple names weren't coerced.new Headers([[1, 2]])rejected a numeric name; names are now coerced to strings the same way values already were.Checklist
tests/unitand/or in Rust for my feature if neededmake fixto format JS and apply Clippy auto fixesmake checktypes/directory (no signature changes)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.