Re: [heycam/webidl] Update attribute setter/getters in various ways (#217)

bzbarsky commented on this pull request.



> +    The <dfn id="dfn-attribute-getter" export>attribute getter</dfn> is created as follows, given an
+    [=attribute=] |attribute|, an [=interface=] |target|, and a [=Realm=] |realm|:
+
+    1.  Let |steps| be the following series of steps:
+        1.  Try running the following steps:
+            1.  Let |O| be <emu-val>null</emu-val>.
+            1.  If |attribute| is not a [=static attribute=]:
+                1.  If the <emu-val>this</emu-val> value is <emu-val>null</emu-val> or
+                    <emu-val>undefined</emu-val>, set |O| to |realm|'s [=Realm/global object=].
+                    (This will subsequently cause a <emu-val>TypeError</emu-val> in a few steps, if
+                    the global object does not implement |target| and [{{LenientThis}}] is not
+                    specified.)
+                    <!-- https://www.w3.org/Bugs/Public/show_bug.cgi?id=18547#c9 -->
+                1.  Otherwise, set |O| to the <emu-val>this</emu-val> value.
+                1.  If |O| is a [=platform object=], then [=perform a security check=], passing |O|,
+                    |realm|, |id|, and "method".

"getter", not "method", right?

> +                    then:
+                    1.  If |attribute| was specified with the [{{LenientThis}}]
+                        [=extended attribute=], then return <emu-val>undefined</emu-val>.
+                    1. Otherwise, <a lt="es throw">throw a <emu-val>TypeError</emu-val></a>.
+            1.  Let |R| be the result of performing the actions listed in the
+                description of |attribute| that occur on getting (or those listed in the description
+                of the inherited attribute, if this attribute is declared to
+                [=inherit its getter=]), on |O| if |O| is not <emu-val>null</emu-val>.
+            1.  Return the result of [=converted to an ECMAScript value|converting=] |R| to an
+                ECMAScript value of the type |attribute| is declared as.
+
+        And then, if an exception was thrown:
+
+        1.  If |attribute|'s type is a [=promise type=], then:
+            1.  Let |reject| be the initial value of [=%Promise%=].reject.
+            1.  Return the result of calling |reject| with [=%Promise%=] as the

Did we ever decide how this should interact with [SameObject]?  Seems to me like we should just disallow [SameObject] on Promise-returning attributes, or change the definition of [SameObject] or something; the current definition of [SameObject] just would not match this new behavior.

I'm still not 100% sure we want to make this behavior change, for what it's worth.  What do UAs do in practice?

> -                extended attribute, then:
-                1.  Let |P| be the identifier of the attribute.
-                1.  Call [=CreateDataProperty=](|O|, |P|, |V|).
+        1.  Let |V| be the value of the first argument passed.
+        1.  Let |id| be |attribute|'s [=identifier=].
+        1.  Let |O| be <emu-val>null</emu-val>.
+        1.  If |attribute| is not a [=static attribute=]:
+            1.  If the <emu-val>this</emu-val> value is <emu-val>null</emu-val> or
+                <emu-val>undefined</emu-val>, set |O| to |realm|'s [=Realm/global object=].
+                (This will subsequently cause a <emu-val>TypeError</emu-val> in a few steps, if
+                the global object does not implement |target| and [{{LenientThis}}] is not
+                specified.)
+                <!-- https://www.w3.org/Bugs/Public/show_bug.cgi?id=18547#c9 -->
+            1.  Otherwise, set |O| to the <emu-val>this</emu-val> value.
+            1.  If |O| is a [=platform object=], then [=perform a security check=], passing |O|,
+                |realm|, |id|, and "method".

"setter", not "method".

> -        that is a [=promise type=], then:
-        1.  Let |reject| be the initial value of [=%Promise%=].reject.
-        1.  Return the result of calling |reject| with [=%Promise%=] as the <emu-val>this</emu-val> object
-            and the exception as the single argument value.
-    1.  Otherwise, end these steps and allow the exception to propagate.
-1.  Let |F| be [=!=] [=CreateBuiltinFunction=](|realm|,
-    |steps|, the [=%FunctionPrototype%=] of |realm|).
-1.  Perform [=!=] [=SetFunctionName=](|F|, |id|).
-1.  Let |S| be the [=effective overload set=] for [=regular operations=] (if |op| is a regular
-    operation) or for [=static operations=] (if |op| is a static operation) with [=identifier=] |id|
-    on |target| and with argument count 0.
-1.  Let |length| be the length of the shortest argument list in the entries in |S|.
-1.  Perform [=!=] [=DefinePropertyOrThrow=](|F|, "length",
-    PropertyDescriptor<span class="prop-desc">{\[[Value]]: |length|, \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>}</span>).
+<div algorithm>
+    To <dfn id="dfn-create-operation-function" lt="creating an operation function">create an operation function</dfn>,

Wish this reindenting were a separate commit....

-- 
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/217#pullrequestreview-7706038

Received on Tuesday, 8 November 2016 20:55:47 UTC