Bug 204544 - `URLSearchParams` cannot be extended
Summary: `URLSearchParams` cannot be extended
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified macOS 10.14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-11-22 19:10 PST by 709922234
Modified: 2020-03-22 10:23 PDT (History)
3 users (show)

See Also:


Attachments
Safari webconsole (50.99 KB, image/png)
2019-11-22 19:10 PST, 709922234
no flags Details
Firefox webconsole (52.59 KB, image/png)
2019-11-22 19:11 PST, 709922234
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description 709922234 2019-11-22 19:10:21 PST
Created attachment 384224 [details]
Safari webconsole

```
class QueryString extends URLSearchParams {
  toString() {
    const string = super.toString();
    return string ? `?${string}` : '';
  }
}
new QueryString({a: 1, b: 2}).toString()
```

Expectation: "?a=1&b=2"
Actual: "a=1&b=2"
Comment 1 709922234 2019-11-22 19:11:00 PST
Created attachment 384225 [details]
Firefox webconsole
Comment 2 Radar WebKit Bug Importer 2019-11-23 12:09:06 PST
<rdar://problem/57454362>
Comment 3 Alexey Shvayka 2020-03-22 10:23:12 PDT
(In reply to 709922234 from comment #0)
> Expectation: "?a=1&b=2"
> Actual: "a=1&b=2"

As of https://trac.webkit.org/changeset/256716, extending URLSearchParams (as well as other DOM constructors) works as expected.