Skip to content

make hooking into maplike and setlike methods easier #824

@heycam

Description

@heycam

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:

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions