Re: [heycam/webidl] Replace serializers by toJSON and [Default] extended attribute (#323)

I was going make a few more tweaks, but it appears "enable edits from collaborators" is not enabled, so here's a diff:

```diff
diff --git a/index.bs b/index.bs
index 3757492..2fd5d64 100644
--- a/index.bs
+++ b/index.bs
@@ -2026,7 +2026,7 @@ Additionaly, in the ECMAScript language binding,
 the <code>toJSON</code> operation can take a [{{Default}}] [=extended attribute=],
 in which case the [=default toJSON operation=] is exposed instead.
 
-<div class="example">
+<div class="example" id="tojson-example">
 
     The following [=IDL fragment=] defines an interface <code class="idl">Transaction</code>
     that has a <code>toJSON</code> method defined in prose:
@@ -2055,18 +2055,18 @@ in which case the [=default toJSON operation=] is exposed instead.
 
     <div algorithm="example tojson">
 
-        To invoke the <code>toJSON</code> operation of the <code class="idl">Transaction</code> interface
-        on |target|, run the following steps:
+        To invoke the <code>toJSON()</code> operation of the <code class="idl">Transaction</code>
+        interface, run the following steps:
 
         1.  Let |json| be a new <code class="idl">TransactionJSONValue</code> dictionary.
-        1.  [=list/For each=] attribute [=identifier=] |attr| in [=list=] « "from", "to", "amount", "description" »:
+        1.  [=list/For each=] attribute [=identifier=] |attr| in « "from", "to", "amount", "description" »:
             1.  Let |value| be result of [=get the underlying value|getting the underlying value=]
-                of [=attribute=] |attr| of <code class="idl">Transaction</code> on |target|.
+                of the [=attribute=] identified by |attr|, given |target|.
             1.  Set |json|[|attr|] to |value|.
         1.  Return |json|.
     </div>
 
-    In the ECMAScript language binding, there would exist a <code>toJSON</code> method on
+    In the ECMAScript language binding, there would exist a <code>toJSON()</code> method on
     <code class="idl">Transaction</code> objects:
 
     <pre highlight="js">
@@ -7897,7 +7897,7 @@ The [{{Default}}] extended attribute must not
 be used on anything other than a [=regular operation=]
 for which a [=corresponding default operation=] has been defined.
 
-<div class="example">
+<div class="example" id="example-tojson-default">
 
     As an example, the [{{Default}}] extended attribute is suitable
     for use on the <code>toJSON</code> [=regular operation=] of the
@@ -10355,7 +10355,7 @@ The characteristics of this property are as follows:
                         [=extended attribute=], then return <emu-val>undefined</emu-val>.
                     1. Otherwise, [=ECMAScript/throw=] a <emu-val>TypeError</emu-val>.
             1.  Let |R| be the result of [=get the underlying value|getting the underlying value=]
-                of |attribute| on |O|.
+                of |attribute| given |O|.
             1.  Return the result of [=converted to an ECMAScript value|converting=] |R| to an
                 ECMAScript value of the type |attribute| is declared as.
 
@@ -10609,7 +10609,7 @@ The [=return type=] of the [=default toJSON operation=] must be {{object}}.
         that is an [=interface member=] of |I|, in order:
         1.  Let |id| be the [=identifier=] of |attr|.
         1.  Let |value| be the result of [=get the underlying value|getting the underlying value=]
-            of |attr| for |O|.
+            of |attr| given |O|.
         1.  If |value| is a [=JSON type=], then [=map/set=] |map|[|id|] to |value|.
     1.  [=list|For each=] [=implements statements=] where the left-hand side [=identifier=] references |I|:
         1.  Let |rhs| be the [=interface=] represented by the right-hand side [=identifier=].
@@ -10635,7 +10635,7 @@ The [=return type=] of the [=default toJSON operation=] must be {{object}}.
     1.  Return |stack|.
 </div>
 
-<div class=example>
+<div class=example id=example-tojson-default-inheritance-and-mixins>
 
     The following [=IDL fragment=] defines a number of [=interfaces=]
     which are [=inherited interface|inherited=] or [=consequential interfaces=] of <code class="idl">A</code>,
@@ -10719,7 +10719,7 @@ The [=return type=] of the [=default toJSON operation=] must be {{object}}.
     }
     </pre>
 
-    An object implementing interface `B` would return:
+    An object implementing interface <code class="idl">B</code> would return:
 
     <pre highlight=json>
     {
```

> It feels sort of icky that the whole default operation is ES-only, especially since the boundary between the IDL part and the ES binding is now so clear.

It seems fine to me. All extended attributes, including [PutForwards], are ES-specific; they're in the ECMAScript binding section. I agree there's some confusing bleed-over, e.g. the interfaces section says which extended attributes are applicable to interfaces; maybe that should be consolidated into the extended attribute definitions instead. But yeah, not worth worrying about for now.

---

Still would be good to replace the PaymentRequest example with a made-up one.

-- 
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/323#issuecomment-302175579

Received on Wednesday, 17 May 2017 18:01:51 UTC