-
Notifications
You must be signed in to change notification settings - Fork 37
Description
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:
- When should instances of the class be constructed?
- Eagerly, inside
register
- Lazily, the first time one is needed by
run
orselectURL
- Lazily, each time one is needed by
run
orselectURL
- Never (
this
would then point at the global)
- Eagerly, inside
- How should the registered operation's
run
property be accessed?- 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.)
- On an instance, during
register
. (This probably implies choosing (i) above, and is similar to storing bound functions.) - 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).