-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Currently the spec allows clear
, delete
, and set
on a maplike interface (and add
, clear
, and delete
on setlike interfaces) to be overridden, 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:
- If key does not contain a hyphen, then throw a TypeError.
- Let keyArg be the result of converting key to an IDL value.
- Let valueArg be the result of converting key to an IDL value.
- 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.
- 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