Re: [w3c/webcomponents] HTML element constructors need to Get(newTarget, "Prototype") (#560)

Yeah, so if it throws, we should rethrow. (That also matches ES.) But what if it returns a non-object? To match ES it should fall back to the [HTMLConstructor] currently executing, I think. Does that sound reasonable to implement?

Following https://tc39.github.io/ecma262/#sec-getprototypefromconstructor exactly, the logic is:

1. Let _prototype_ be Get(NewTarget, "prototype"). Rethrow any exceptions.
1. If Type(_prototype_) is not Object,
  1. Let _realm_ be GetFunctionRealm(NewTarget).
  1. Set _prototype_ to the [interface prototype object] of _realm_ whose [interface] is the same as that of the [active function object].

(Using [] to denote links to spec terms in IDL/ES.)

Note that in the last step _realm_ can be different from [the current Realm record], which is even more subtle fun. I'll be sure to write some test cases.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/560#issuecomment-244092135

Received on Thursday, 1 September 2016 14:16:04 UTC