Skip to content

Consider defining a Realm (global) for all objects, not just Functions #1333

Open
@bzbarsky

Description

@bzbarsky

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:

  1. If the [[Get]] throws, the exception needs to be reported to the error handler on a global. Which global?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    layeringaffects the public spec interface and may require updates to integrating specsneeds specification textThe proposal should specify ecmarkup changes that can easily merge into tc39/ecma262/spec.html.web reality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions