Re: [heycam/webidl] Does WebIDL define whether or not the interface constructor should be exposed on the global? (#820)

[`[Exposed]`](https://heycam.github.io/webidl/#Exposed) describes the ‘exposure set’ of an interface. Its value is one or more identifiers of interfaces that have the [`[Global]`](https://heycam.github.io/webidl/#Global) extended attribute — e.g. `Window`, `Worklet`, etc.

If the exposure set of an interface is `Window`, this means the interface exists in realms whose global object is `Window`, but not otherwise. By default, when exposed, it does also mean that the constructor will be made available as a property of the global object whose key is the name of the interface. But another extended attribute, [`[NoInterfaceObject]`](https://heycam.github.io/webidl/#NoInterfaceObject), modifies that behavior: it makes it so that the constructor does not appear as a global property. The example you gave, `Geolocation`, uses `[NoInterfaceObject]`, which is why a global property isn’t created for its constructor.

Whether to create a property is a distinct concept from exposure. The interface object and its instances cannot exist at all in a realm whose global object is not in its exposure set.

New interfaces aren’t meant to use `[NoInterfaceObject]`. It’s around for legacy reasons.

>  Chrome's case for navigator, <instance>.constructor seems to point to different version of that, even when <instance>.constructor.prototype is pointing to the same object. Is this a bug in the implementation, or something not defined in WebIDL?

I believe there is just a typo in your test here. You wrote `window.navigator.constructor === window.navigator` instead of `window.navigator.constructor === window.Navigator`.

-- 
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/820#issuecomment-551989823

Received on Friday, 8 November 2019 21:07:02 UTC