[heycam/webidl] State that by default all objects are created in the relevant realm of `this` (#135)

This has come up recently in https://github.com/w3c/webcrypto/issues/85 and also in some internal work Blink is doing on refactoring their bindings layer.

It appears that in all browsers, document.createElement, innerHTML, and an Event created through button.click() are created in the relevant realm of `this`. All of these cases are currently unspecified and use spec text equivalent to "create a new X object".

We should specify a few things:

- If an IDL method or attribute is currently executing, "a new X object" means creating it in the relevant realm of `this`
- If an IDL constructor is currently executing, "a new X object" means creating it in the current realm
- If neither of these conditions hold, e.g. in steps that are being executed in parallel or in tasks that are posted to the event loop, "a new X object" *must* be accompanied by a specification of what realm to create the object in.

(At first I thought that we should follow the ES spec and use the current realm for all cases. That would better match e.g. `Array.prototype.map` or `Promise.prototype.then`. But it seems like that's not what browsers do, so we'll just have to live with the inconsistency.)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/135

Received on Tuesday, 19 July 2016 19:13:00 UTC