Skip to content

Commit fc9fc6d

Browse files
committed
Revert "Implement support for the [Exposed] extended attribute (#192)"
This reverts commit 464a43f as part of rollback to before recent breaking changes, so we can make a new v15 release.
1 parent 1ea0bf6 commit fc9fc6d

File tree

4 files changed

+81
-463
lines changed

4 files changed

+81
-463
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,10 @@ Performs the Web IDL conversion algorithm for this interface, converting _value_
264264

265265
In practice, this means doing a type-check equivalent to `is(value)`, and if it passes, returns the corresponding impl. If the type-check fails, it throws an informative exception. _context_ can be used to describe the provided value in any resulting error message.
266266

267-
#### `install(globalObject, globalNames)`
267+
#### `install(globalObject)`
268268

269269
This method creates a brand new wrapper constructor and prototype and attach it to the passed `globalObject`. It also registers the created constructor with the `globalObject`'s global constructor registry, which makes `create()`, `createImpl()`, and `setup()` work. (Thus, it is important to invoke `install()` before invoking those methods, as otherwise they will throw.)
270270

271-
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.
272-
273271
#### `create(globalObject, constructorArgs, privateData)`
274272

275273
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.
@@ -456,7 +454,6 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S
456454
- Variadic arguments
457455
- `[Clamp]`
458456
- `[EnforceRange]`
459-
- `[Exposed]`
460457
- `[LegacyArrayClass]`
461458
- `[LegacyUnenumerableNamedProperties]`
462459
- `[LegacyWindowAlias]`
@@ -481,6 +478,7 @@ Notable missing features include:
481478
- `[AllowShared]`
482479
- `[Default]` (for `toJSON()` operations)
483480
- `[Global]`'s various consequences, including the named properties object and `[[SetPrototypeOf]]`
481+
- `[Exposed]`
484482
- `[LenientSetter]`
485483
- `[LenientThis]`
486484
- `[NamedConstructor]`

lib/constructs/callback-interface.js

+1-32
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,6 @@ class CallbackInterface {
2020

2121
this._analyzed = false;
2222
this._outputStaticProperties = new Map();
23-
24-
const exposed = utils.getExtAttr(this.idl.extAttrs, "Exposed");
25-
if (this.idl.members.some(member => member.type === "const") && !exposed) {
26-
throw new Error(`Callback interface ${this.name} with defined constants lacks the [Exposed] extended attribute`);
27-
}
28-
29-
if (exposed) {
30-
if (!exposed.rhs || (exposed.rhs.type !== "identifier" && exposed.rhs.type !== "identifier-list")) {
31-
throw new Error(`[Exposed] must take an identifier or an identifier list in callback interface ${this.name}`);
32-
}
33-
34-
if (exposed.rhs.type === "identifier") {
35-
this.exposed = new Set([exposed.rhs.value]);
36-
} else {
37-
this.exposed = new Set(exposed.rhs.value.map(token => token.value));
38-
}
39-
} else {
40-
this.exposed = new Set();
41-
}
4223
}
4324

4425
_analyzeMembers() {
@@ -197,24 +178,14 @@ class CallbackInterface {
197178
}
198179

199180
generateInstall() {
200-
if (this.constants.size > 0) {
201-
this.str += `
202-
const exposed = new Set(${JSON.stringify([...this.exposed])});
203-
`;
204-
}
205-
206181
this.str += `
207-
exports.install = (globalObject, globalNames) => {
182+
exports.install = function install(globalObject) {
208183
`;
209184

210185
if (this.constants.size > 0) {
211186
const { name } = this;
212187

213188
this.str += `
214-
if (!globalNames.some(globalName => exposed.has(globalName))) {
215-
return;
216-
}
217-
218189
const ${name} = () => {
219190
throw new TypeError("Illegal invocation");
220191
};
@@ -263,6 +234,4 @@ class CallbackInterface {
263234
}
264235
}
265236

266-
CallbackInterface.prototype.type = "callback interface";
267-
268237
module.exports = CallbackInterface;

lib/constructs/interface.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1463,12 +1463,7 @@ class Interface {
14631463
const { idl, name } = this;
14641464

14651465
this.str += `
1466-
const exposed = new Set(${JSON.stringify([...this.exposed])});
1467-
1468-
exports.install = (globalObject, globalNames) => {
1469-
if (!globalNames.some(globalName => exposed.has(globalName))) {
1470-
return;
1471-
}
1466+
exports.install = (globalObject, globalName) => {
14721467
`;
14731468

14741469
if (idl.inheritance) {
@@ -1505,7 +1500,7 @@ class Interface {
15051500

15061501
if (this.legacyWindowAliases) {
15071502
this.str += `
1508-
if (globalNames.includes("Window")) {
1503+
if (globalName === "Window") {
15091504
`;
15101505

15111506
for (const legacyWindowAlias of this.legacyWindowAliases) {

0 commit comments

Comments
 (0)