Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of operation instances is unclear #170

Open
jeremyroman opened this issue Aug 9, 2024 · 0 comments
Open

Use of operation instances is unclear #170

jeremyroman opened this issue Aug 9, 2024 · 0 comments

Comments

@jeremyroman
Copy link
Contributor

jeremyroman commented Aug 9, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant