Commit 2fa428f
committed
fix: URLSearchParams construction and iteration spec compliance
The constructor previously handled only the string init form; any object
init was stringified to "[object Object]", collapsing every query
parameter into a single bogus key. It now follows the WHATWG/WebIDL init
dispatch (https://url.spec.whatwg.org/#interface-urlsearchparams):
record, sequence (any iterable of pairs: Array, Map, Set, another
URLSearchParams, generators - with IteratorClose on abrupt completion),
other primitives (USVString coercion; Symbol throws), and
null/undefined (empty).
entries()/keys()/values() returned plain v8::Arrays and the type exposed
no @@iterator, so for..of, spread, and the copy-constructor form did not
work; the array path also returned the first value for every occurrence
of a repeated key. They now return genuine live ES iterators (reflecting
mutations mid-iteration, per spec), and @@iterator aliases entries().
Also aligned to spec: get() returns null (not undefined) for a missing
name; delete(name, value) and has(name, value) honor the optional value
argument (coerced to USVString; an explicit undefined is treated as
omitted, matching WPT).1 parent cd28c41 commit 2fa428f
2 files changed
Lines changed: 804 additions & 101 deletions
0 commit comments