Description
A specific motivating example is the DOM event listener API. This takes an object which can be a function or can be an object with a handleEvent
property. In the latter case, when the event fires, the value of the property is gotten (via [[Get]]
) and then called as a function.
This raises at least two problems in terms of DOM integration:
-
If the
[[Get]]
throws, the exception needs to be reported to the error handler on a global. Which global? -
If the property getter is a bound version of the
postMessage
function, which wants to examine the "global of its caller", how should that be defined in this case? That is, where does the event processing algorithm get a global before it calls[[Get]]
? There are attempts to remove this "global of its caller" concept in Minimize the usage of the incumbent concept whatwg/html#1430 but at the moment it's not really making progress.
There are similar issues with Promise integration into the DOM, last I checked, but I don't recall the details. Maybe @domenic might.
Anyway, in the past there has been some resistance to defining a Realm for all objects, but maybe it's worth looking into the issue again.
// cc @littledan