Re: [whatwg/webidl] Normative: Add DOMException cause (PR #1179)

@annevk commented on this pull request.

I have some editorial suggestions. This also aligns the IDL with the style we used for `addEventListener()`. Essentially downplaying the role of the legacy argument type which also simplifies the resulting algorithm a bit.

> @@ -14559,10 +14559,16 @@ The {{DOMException}} type is an [=interface type=] defined by the following IDL
 fragment:
 
 <pre class="idl">
+
+dictionary DOMExceptionOptions {
+  any cause;
+  DOMString name;

```suggestion
  DOMString name = "Error";
```

>  [Exposed=(Window,Worker),
  Serializable]
 interface DOMException { // but see below note about ECMAScript binding
-  constructor(optional DOMString message = "", optional DOMString name = "Error");
+  constructor(optional DOMString message = "", optional (DOMString or DOMExceptionOptions) nameOrOptions = "Error");

```suggestion
  constructor(optional DOMString message = "", optional (DOMString or DOMExceptionOptions) options = {});
```

> +1.  If |nameOrOptions| is a String, set [=this=]'s [=DOMException/name=] to
+    |nameOrOptions|.

```suggestion
1.  If |options| is a string, then set [=this=]'s [=DOMException/name=] to |options|.
```

>  constructor steps are:
 
-1. Set [=this=]'s [=DOMException/name=] to |name|.
-1. Set [=this=]'s [=DOMException/message=] to |message|.
+1.  Set [=this=]'s [=DOMException/message=] to |message|.
+1.  If |nameOrOptions| is a String, set [=this=]'s [=DOMException/name=] to
+    |nameOrOptions|.
+1.  Else,

```suggestion
1.  Otherwise:
```

> +    1.  If |nameOrOptions|'name is present, set [=this=]'s [=DOMException/name=]
+        to |nameOrOptions|'s name, else set [=this=]'s [=DOMException/name=]
+        to "Error".
+    1.  Perform [=?=] <a abstract-op>InstallErrorCause</a>([=this=], |nameOrOptions|).

```suggestion
    1.  Set [=this=]'s [=DOMException/name=] to |options|["{{DOMExceptionOptions/name}}"].
    1.  Perform [=?=] <a abstract-op>InstallErrorCause</a>([=this=], |options|).
```

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

Message ID: <whatwg/webidl/pull/1179/review/1092877066@github.com>

Received on Thursday, 1 September 2022 07:19:06 UTC