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

@domenic requested changes on this pull request.



>  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 |options| is a string, then set [=this=]'s [=DOMException/name=] to |options|.
+1.  Otherwise,
+    1.  Set [=this=]'s [=DOMException/name=] to |options|["{{DOMExceptionOptions/name}}"].
+    1.  Perform [=?=] <a abstract-op>InstallErrorCause</a>([=this=], |options|).

It's not good that InstallErrorCause() performs HasProperty() and Get(), which the Web IDL bindings layer has already done.

It's also not really valid spec text to pass |options|, which is a Web IDL dictionary at this point, to InstallErrorCause(), which expects a JavaScript object. (Although, we do often fudge these boundaries; I've certainly done it myself.)

I think we should instead duplicate the InstallErrorCause logic here:

2. If |options|["cause"] [=map/exists=], then perform [CreateNonEnumerableDataPropertyOrThrow](https://tc39.es/ecma262/#sec-createnonenumerabledatapropertyorthrow)(O, "cause", |options|["cause"]).

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

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

Received on Monday, 5 September 2022 02:56:39 UTC