I want to Subclass a Proxied
ES6 Class. It works just fine in Firefox and Chrome, but Safari 10 throws an error:
let SuperClass = class {
constructor() {
console.log('SuperClass constructor')
}
}
let ProxiedSuperClass = new Proxy(SuperClass, {});
let SubClass = class extends ProxiedSuperClass {
constructor() {
super();
console.log('SubClass constructor')
}
}
var s = new SubClass();
// Expected output (Firefox, Chrome):
// SuperClass constructor
// SubClass constructor
// Safari output:
// function is not a constructor (evaluating 'super()')
So, Safari seems to try to extend Proxy
, while Firefox and Chrome extend SuperClass
.
What's the correct behaviour here? Is it just not possible (or well defined) to proxy a Class? Or can I somehow hint Safari to do "the right thing", i.e. to subclass SuperClass
instead of Proxy
?