Skip to content

Commit f717fd4

Browse files
committed
Temporarily make [Exposed] and globalNames non-required
This reverts the breaking changes introduced in #191, since it was accidentally released as a minor version in v15.2.0, while keeping the functionality.
1 parent 8d82d5a commit f717fd4

File tree

5 files changed

+81
-74
lines changed

5 files changed

+81
-74
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ This method creates a brand new wrapper constructor and prototype and attach it
270270

271271
The second argument `globalNames` is an array containing the [global names](https://heycam.github.io/webidl/#dfn-global-name) of the interface that `globalObject` implements. This is used for the purposes of deciding which interfaces are [exposed](https://heycam.github.io/webidl/#dfn-exposed). For example, this array should be `["Window"]` for a [`Window`](https://html.spec.whatwg.org/multipage/window-object.html#window) global object. But for a [`DedicatedWorkerGlobalScope`](https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope) global object, this array should be `["Worker", "DedicatedWorker"]`. Note that we do not yet implement [`[SecureContext]`](https://heycam.github.io/webidl/#SecureContext), so the "exposed" check is not fully implemented.
272272

273+
Temporarily, until the next major release, `globalNames` defaults to `["Window"]`.
274+
273275
#### `create(globalObject, constructorArgs, privateData)`
274276

275277
Creates a new instance of the wrapper class and corresponding implementation class, passing in the `globalObject`, the `constructorArgs` array and `privateData` object to the implementation class constructor. Then returns the wrapper class.
@@ -304,10 +306,12 @@ The resulting function has an _objectReference_ property, which is the same obje
304306

305307
If any part of the conversion fails, _context_ can be used to describe the provided value in any resulting error message.
306308

307-
#### `install(globalObject)`
309+
#### `install(globalObject, globalNames)`
308310

309311
If this callback interface has constants, then this method creates a brand new legacy callback interface object and attaches it to the passed `globalObject`. Otherwise, this method is a no-op.
310312

313+
The second argument `globalNames` is the same as for [the `install()` export for interfaces](#installglobalobject-globalnames). (However, it does not have a default.)
314+
311315
### For dictionaries
312316

313317
#### `convert(value, { context })`
@@ -462,7 +466,7 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S
462466
- Variadic arguments
463467
- `[Clamp]`
464468
- `[EnforceRange]`
465-
- `[Exposed]`
469+
- `[Exposed]` (temporarily defaulting to `[Exposed=Window]`)
466470
- `[LegacyArrayClass]`
467471
- `[LegacyUnenumerableNamedProperties]`
468472
- `[LegacyWindowAlias]`

lib/constructs/interface.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ class Interface {
9292
this.exposed = new Set();
9393
}
9494

95-
if (!exposed && !utils.getExtAttr(this.idl.extAttrs, "NoInterfaceObject")) {
96-
throw new Error(`Interface ${this.name} has neither [Exposed] nor [NoInterfaceObject]`);
95+
// TODO: put back in next major version.
96+
// if (!exposed && !utils.getExtAttr(this.idl.extAttrs, "NoInterfaceObject")) {
97+
// throw new Error(`Interface ${this.name} has neither [Exposed] nor [NoInterfaceObject]`);
98+
// }
99+
// For now:
100+
if (!exposed) {
101+
this.exposed = new Set(["Window"]);
97102
}
98103

99104
const legacyWindowAlias = utils.getExtAttr(this.idl.extAttrs, "LegacyWindowAlias");
@@ -1486,7 +1491,7 @@ class Interface {
14861491
this.str += `
14871492
const exposed = new Set(${JSON.stringify([...this.exposed])});
14881493
1489-
exports.install = (globalObject, globalNames) => {
1494+
exports.install = (globalObject, globalNames = ["Window"]) => {
14901495
if (!globalNames.some(globalName => exposed.has(globalName))) {
14911496
return;
14921497
}

0 commit comments

Comments
 (0)