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

domenic commented on this pull request.



> +        1.  If |descriptor| has a \[[Configurable]] field and |descriptor|.\[[Configurable]] is
+            <emu-val>false</emu-val>, return <emu-val>false</emu-val>.
+        1.  If |descriptor| has a \[[Enumerable]] field and |descriptor|.\[[Enumerable]] is
+            <emu-val>false</emu-val>, return <emu-val>false</emu-val>.
+        1.  If |descriptor| has a \[[Writable]] field and |descriptor|.\[[Writable]] is
+            <emu-val>false</emu-val>, return <emu-val>false</emu-val>.
+        1.  If [=!=] [$ToUint32$](|P|) > |oldLen|, return <emu-val>false</emu-val>.
+        1.  Let |idlValue| be the result of [=converted to an IDL value|converting=]
+            |descriptor|.\[[Value]] to the type given by |handler|.\[[Type]].
+        1.  Let |existingDescriptor| be [=!=] [$OrdinaryGetOwnProperty$](|O|, |P|).
+        1.  Assert: |existingDescriptor| is not <emu-val>undefined</emu-val>.
+        1.  Let |existingIDLValue| be the result of [=converted to an IDL value|converting=]
+            |existingDescriptor|.\[[Value]] to the type given by |handler|.\[[Type]].
+        1.  Assert: the above step never throws an exception, since we already went through the
+            conversions when we first stored the value.
+        1.  Perform the algorithm steps given by |handler|.\[[DeleteAlgorithm]], given

We could add a shared reentrancy guard into every proxy trap (or at least every mutating proxy trap). I.e. a per-handler [[IsMutating]] boolean which, if true, causes any mutating proxy traps to throw immediately. Do you think it's worth it?

Given that the only example of delete/set callbacks that we have is [this very simple one](https://github.com/WICG/construct-stylesheets/pull/117/files#diff-ec9cfa5f3f35ec1f84feb2e59686c34dR198) I'm not sure whether this would be "setting ourselves up to avoid future problems", or "overbuilding complicated infrastructure we won't really need".

Maybe the middle road is to add just some prose prohibition on calling JS code or mutating the backing list from these handlers, and assume spec authors will follow it.

-- 
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_r382240029

Received on Thursday, 20 February 2020 20:28:47 UTC