Bug 198674

Summary: Can't extend host objects like URLSearchParameters using JS classes
Product: WebKit Reporter: Mikhail V <webrealizer>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: 709922234, achristensen, ashvayka, fpizlo, keith_miller, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Safari 12   
Hardware: Mac   
OS: macOS 10.14   
See Also: https://bugs.webkit.org/show_bug.cgi?id=174313

Mikhail V
Reported 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.
Attachments
Radar WebKit Bug Importer
Comment 1 2019-06-07 19:02:49 PDT
Alexey Shvayka
Comment 2 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.
Note You need to log in before you can comment on or make changes to this bug.