Re: [heycam/webidl] Make interface prototype object creation imperative (#494)

domenic commented on this pull request.



> -        return the [=named properties object=]
-        for |A|, as defined in [[#named-properties-object]].
-    1.  Otherwise, if |A| is declared to inherit from another
-        interface, then return the
-        [=interface prototype object=]
-        for the inherited interface.
-    1.  Otherwise, if |A| is declared with the [{{LegacyArrayClass}}]
-        extended attribute, then return {{%ArrayPrototype%}}.
-    1.  Otherwise, return {{%ObjectPrototype%}}.
+    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.

Also should state the interface prototype object in _realm_.

> +        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to |realm|.\[[Intrinsics]].[[{{%ArrayPrototype%}}]].
+    1.  Otherwise, set |proto| to |realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]].
+    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(|proto|).
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Let |unscopableObject| be the result of performing [=!=]
+            <a abstract-op>ObjectCreate</a>(|realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]]).
+        1.  Let |desc| be the PropertyDescriptor{\[[Value]]: |unscopableObject|,
+            \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>,
+            \[[Configurable]]: <emu-val>true</emu-val>}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).

Style nit/matter of preference: I would install the property after filling it up with values, so move the following step up above these two.

> +    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(|proto|).
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Let |unscopableObject| be the result of performing [=!=]
+            <a abstract-op>ObjectCreate</a>(|realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]]).
+        1.  Let |desc| be the PropertyDescriptor{\[[Value]]: |unscopableObject|,
+            \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>,
+            \[[Configurable]]: <emu-val>true</emu-val>}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).
+        1.  [=list/For each=] [=exposed=] [=member=] |member| of |interface|
+            that is declared with the [{{Unscopable}}] [=extended attribute=]:
+            1.  Let |id| be |member|'s [=identifier=].
+            1.  Perform [=!=] <a abstract-op>CreateDataProperty</a>(|unscopableObject|, |id|,
+                <emu-val>true</emu-val>).
+    1.  [=Expose the regular attributes=] of |interface| on |interfaceProtoObj| given |realm|.
+    1.  [=list/For each=] [=exposed=] [=regular operation=] |op| that is a [=member=] of |interface|:

Why did the other two get their own dedicated "expose the X"s, but not regular operations?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/494#pullrequestreview-84569948

Received on Tuesday, 19 December 2017 19:52:07 UTC