Intent to Implement/Ship
------------------------
Change URLSearchparams' constructor from
Constructor(optional (sequence<sequence<USVString>> or USVString or URLSearchParams) init = "")
to
Constructor(optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init = ""),
Contact emails
--------------
raphael.ku...@intel.com
Spec
----
https://url.spec.whatwg.org/#interface-urlsearchparams
Summary
-------
In January 2017,
https://github.com/whatwg/url/pull/175 was merged into
the URL spec. It changed the union in URLSearchParams' constructor from
(USVString or URLSearchParams)
to the long one mentioned above.
Blink's implementation gained support for sequence<sequence<USVString>>
in March, but we still didn't support records and explicitly accepted
URLSearchParams in the union.
By supporting records and sequences in the union we also accept any
object; per WebIDL, if the object has a @@iterator (URLSearchParams
does), it is converted to a sequence, otherwise it's treated as a
record.
Motivation
----------
Align Blink's implementation with the spec, which also makes us pass
more tests from web-platform-tests and reduce interoperability issues.
Interoperability risk
---------------------
Firefox:
- Dropped URLSearchParams from the constructor in 53
https://bugzilla.mozilla.org/show_bug.cgi?id=1330678
- Added record<USVString, USVString> to the union in 54
https://bugzilla.mozilla.org/show_bug.cgi?id=1331580
Edge:
- Does not seem to implement URLSearchParams at all
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8993198/
WebKit:
- Implemented a similar change in January 2017
https://bugs.webkit.org/show_bug.cgi?id=166973
Compatibility risk
------------------
Passing a URLSearchParams to the constructor is still supported, but it
is processed differently. While we used to have URLSearchParams as a
union member in the past and just copy the parameters to the new object,
we now initialize the new object by converting the existing
URLSearchParams to a sequence<sequence<USVString, USVString>> (I don't
see a big difference in practice).
Passing an object without an @@iterator symbol (e.g. `new
URLSearchParams({})`) now causes the object to be processed as a record
instead of as a plain string. In other words,
new URLSearchParams({}).toString()
used to return "%5Bobject+Object%5D=", and it returns an empty string
now.
Is this feature supported on all six Blink platforms?
-----------------------------------------------------
Yes.
Is this feature fully tested by web-platform-tests?
---------------------------------------------------
Yes.
Related bug report
------------------
https://bugs.chromium.org/p/chromium/issues/detail?id=697378
Requesting approval to ship the behavior change
-----------------------------------------------
Yes, in master (M61).