这是indexloc提供的服务,不要输入任何密码
Skip to content

Use of operation instances is unclear #170

@jeremyroman

Description

@jeremyroman

In the spec, register(name, operationCtor) constructs an instance eagerly in order to get the run function. On the other hand, the Chromium implementation retrieves this function from the prototype without constructing it.

In the spec, no this value is supplied to the run callback invocation (which would almost certainly confusing to authors). In the Chromium implementation, an instance is constructed lazily the first time run is to be invoked, and that instance is used.

Basically, what needs to be decided is:

  1. When should instances of the class be constructed?
    1. Eagerly, inside register
    2. Lazily, the first time one is needed by run or selectURL
    3. Lazily, each time one is needed by run or selectURL
    4. Never (this would then point at the global)
  2. How should the registered operation's run property be accessed?
    1. On an instance, each time the operation is invoked. (This probably implies choosing (ii) or (iii) above, and is similar to how JavaScript code normally invokes functions on objects.)
    2. On an instance, during register. (This probably implies choosing (i) above, and is similar to storing bound functions.)
    3. On the prototype, during register. (This probably implies not choosing (i) above, and is similar to how custom elements stores callbacks.)

Whatever the choices are, the spec and Chromium implementations should be updated to match, and the "callback this value" passed to invoke should be set accordingly (this may involve additional plumbing to get the object instance to the place where "invoke a callback function" is used).

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