Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unscopeable] is now [Unscopable] #95

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S
- `[SameObject]` (automatic caching)
- `[TreatNullAs]`
- `[Unforgeable]`
- `[Unscopeable]`
- `[Unscopable]`

Notable missing features include:

Expand Down
2 changes: 1 addition & 1 deletion lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ class Interface {
generateSymbols() {
const unscopables = Object.create(null);
for (const member of this.idl.members) {
if (utils.getExtAttr(member.extAttrs, "Unscopeable")) {
if (utils.getExtAttr(member.extAttrs, "Unscopable")) {
unscopables[member.name] = true;
}
}
Expand Down
141 changes: 141 additions & 0 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6465,6 +6465,147 @@ const Impl = require(\\"../implementations/UnforgeableMap.js\\");
"
`;

exports[`Unscopable.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
const utils = require(\\"./utils.js\\");

const impl = utils.implSymbol;

function Unscopable() {
throw new TypeError(\\"Illegal constructor\\");
}

Object.defineProperty(Unscopable, \\"prototype\\", {
value: Unscopable.prototype,
writable: false,
enumerable: false,
configurable: false
});

Object.defineProperty(Unscopable.prototype, \\"unscopableTest\\", {
get() {
if (!this || !module.exports.is(this)) {
throw new TypeError(\\"Illegal invocation\\");
}

return this[impl][\\"unscopableTest\\"];
},

set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError(\\"Illegal invocation\\");
}

V = conversions[\\"boolean\\"](V, {
context: \\"Failed to set the 'unscopableTest' property on 'Unscopable': The provided value\\"
});

this[impl][\\"unscopableTest\\"] = V;
},

enumerable: true,
configurable: true
});

Object.defineProperty(Unscopable.prototype, Symbol.unscopables, {
value: {
unscopableTest: true
},
writable: false,
enumerable: false,
configurable: true
});

Object.defineProperty(Unscopable.prototype, Symbol.toStringTag, {
value: \\"Unscopable\\",
writable: false,
enumerable: false,
configurable: true
});

const iface = {
// When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\`
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
// implementing this mixin interface.
_mixedIntoPredicates: [],
is(obj) {
if (obj) {
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
return true;
}
for (const isMixedInto of module.exports._mixedIntoPredicates) {
if (isMixedInto(obj)) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}

const wrapper = utils.wrapperForImpl(obj);
for (const isMixedInto of module.exports._mixedIntoPredicates) {
if (isMixedInto(wrapper)) {
return true;
}
}
}
return false;
},
convert(obj, { context = \\"The provided value\\" } = {}) {
if (module.exports.is(obj)) {
return utils.implForWrapper(obj);
}
throw new TypeError(\`\${context} is not of type 'Unscopable'.\`);
},

create(constructorArgs, privateData) {
let obj = Object.create(Unscopable.prototype);
obj = this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Unscopable.prototype);
obj = this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};

privateData.wrapper = obj;

this._internalSetup(obj);
Object.defineProperty(obj, impl, {
value: new Impl.implementation(constructorArgs, privateData),
writable: false,
enumerable: false,
configurable: true
});

obj[impl][utils.wrapperSymbol] = obj;
if (Impl.init) {
Impl.init(obj[impl], privateData);
}
return obj;
},
interface: Unscopable,
expose: {
Window: { Unscopable }
}
}; // iface
module.exports = iface;

const Impl = require(\\"../implementations/Unscopable.js\\");
"
`;

exports[`Variadic.webidl 1`] = `
"\\"use strict\\";

Expand Down
3 changes: 3 additions & 0 deletions test/cases/Unscopable.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Unscopable {
[Unscopable] attribute boolean unscopableTest;
};