Bug 198674 - Can't extend host objects like URLSearchParameters using JS classes
Summary: Can't extend host objects like URLSearchParameters using JS classes
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: Safari 12
Hardware: Mac macOS 10.14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-06-07 13:09 PDT by Mikhail V
Modified: 2020-04-17 15:00 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail V 2019-06-07 13:09:51 PDT
This is something that works in other browsers like Chrome but fails in Safari. 

Try executing code like this

class MyParams extends URLSearchParams {
  constructor(init) {
    super(init)
  }
  test() {
    alert(1);
  }
}

var s1 = new MyParams();

s1.test(); // Works in Chrome but breaks in Safari. 

I understand that extending host object might be just prohibited but it is hard to find any docs on that or confirmation. 

Could you clarify what is going on here and why WebKit team decided to block something useful like this.
Comment 1 Radar WebKit Bug Importer 2019-06-07 19:02:49 PDT
<rdar://problem/51543664>
Comment 2 Alexey Shvayka 2020-04-17 15:00:12 PDT
(In reply to Mikhail V from comment #0)
> s1.test(); // Works in Chrome but breaks in Safari. 

As of r256716, extending URLSearchParams (as well as other DOM constructors) works as expected.