Re: [whatwg/webidl] Disallow non-attribute frozen arrays (PR #1413)

@domenic commented on this pull request.



> +            undefined randomizeFavoriteColors();
+        };
+    </pre>
+
+    The behavior of these attributes could be defined like so:
+
+    <blockquote>
+        Each <code>PersonalPreferences</code> has associated <b>favorite colors</b>, a {{FrozenArray}}&lt;{{DOMString}}>, initially equal to the result of [=creating a frozen array=] from « "<code>purple</code>", "<code>aquamarine</code>" ».
+
+        Each <code>PersonalPreferences</code> has an associated <b>favorite foods</b>, a {{FrozenArray}}&lt;{{DOMString}}>, initially equal to the result of [=creating a frozen array=] from the empty list.
+
+        The <code>favoriteColors</code> [=getter steps=] are to return [=this=]'s favorite colors.
+
+        The <code>favoriteFoods</code> [=getter steps=] are to return [=this=]'s favorite foods.
+
+        The <code>favoriteFoods</code> [=setter steps=] are to set [=this=]'s favorite foods to [=the given value=].

The conversion steps for JS values to Web IDL `FrozenArray<T>` types will take any iterable, iterate over it, grab the values into an Infra list, then create a JS array from them, then freeze it, then package it up into a `FrozenArray<T>` pointer. So yeah, it just works.

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

Message ID: <whatwg/webidl/pull/1413/review/2150678342@github.com>

Received on Monday, 1 July 2024 07:54:03 UTC