[heycam/webidl] make hooking into maplike and setlike methods easier (#824)

Currently the spec allows `clear`, `delete`, and `set` on a maplike interfaces (and `add`, `clear`, and `delete` on setlike interfaces) so that spec authors can add validation of inserted keys and values, and to respond to changes in the contents of the backing map or set.

The prose required to do this is a bit awkward.  For example, to override `set` to add syntax checking for the key argument, you would need to write something like this:

> The **set(key, value)** method on the Foo interface, when invoked, must run these steps:
> 1. If _key_ does not contain a hyphen, then throw a TypeError.
> 2. Let _keyArg_ be the result of converting key to an IDL value.
> 3. Let _valueArg_ be the result of converting key to an IDL value.
> 4. Let _result_ be the result of running the steps for a built-in maplike set function, with the context object as the **this** object, and with arguments _keyArg_ and _valueArg_.
> 5. Return _result_.

I think it may be better to disallow overriding these methods, but instead to have some spec hooks that are invoked from the built-in `add`, `clear`, `delete`, and `set` functions.  That way the spec author can remain in IDL value land and doesn't need to deal with invoking the built-in steps.

cc @frivoal

-- 
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/issues/824

Received on Tuesday, 10 December 2019 04:35:55 UTC