Re: [heycam/webidl] Introduce the observable array type (proxy-based) (#840)

bzbarsky commented on this pull request.



> +    1.  If |P| is "length", then return the result of
+        [=observable array exotic object/setting the length=] given |handler| and |V|.
+    1.  If |P| [=is an array index=], then return the result of
+        [=observable array exotic object/setting the indexed value=] given |handler|, |P|, and |V|.
+    1.  Return [=?=] |O|.\[[Set]](|P|, |V|, |Receiver|).
+</div>
+
+<h4 id="es-observable-array-abstract-operations">Abstract operations</h4>
+
+<div algorithm>
+    To <dfn for="observable array exotic object" lt="set the length|setting the length">set the length</dfn>
+    of an observable array exotic object given |handler| and |newLen|: 
+
+    1.  Set |newLen| to [=?=] [$ToUint32$](|newLen|).
+    1.  Let |numberLen| be [=?=] [$ToNumber$](|newLen|).
+    1.  If |newLen| ≠ |numberLen|, then throw a {{RangeError}} exception.

> This is modeled on https://tc39.es/ecma262/#sec-arraysetlength


Huh.  Indeed, that does the to-number conversion twice, look at that.  Alright then; we should stay compatible with that but make sure we add tests for it (using a `Symbol.toPrimitive` with side-effects on an object that `length` is then set to).

-- 
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/840#discussion_r391870279

Received on Thursday, 12 March 2020 20:15:05 UTC