Skip to content
Closed
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
20 changes: 20 additions & 0 deletions lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,26 @@ class Interface {
const props = [...classProps].map(([name, body]) => `${name}: ${body}`);
this.str += `Object.defineProperties(${this.name}, { ${props.join(", ")} });`;
}

// This code can't currently be generated as the operation, parameters
// and overloads code doesn't currently support symbol properties.
// This method is also made non-enumerable to match the other 'utils' symbol properties.
this.str += `

if (utils.hasOwn(Impl.implementation.prototype, utils.inspectCustomSymbol)) {
Object.defineProperty(${this.name}.prototype, utils.inspectCustomSymbol, {
value(depth, ctx) {
if (!exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl][utils.inspectCustomSymbol](...arguments);
},
writable: true,
enumerable: false,
configurable: true
});
}
`;
}

generateOnInstance() {
Expand Down
2 changes: 2 additions & 0 deletions lib/output/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const wrapperSymbol = Symbol("wrapper");
const implSymbol = Symbol("impl");
const sameObjectCaches = Symbol("SameObject caches");
const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
const inspectCustomSymbol = Symbol.for("nodejs.util.inspect.custom");

function getSameObject(wrapper, prop, creator) {
if (!wrapper[sameObjectCaches]) {
Expand Down Expand Up @@ -91,6 +92,7 @@ module.exports = exports = {
implSymbol,
getSameObject,
ctorRegistrySymbol,
inspectCustomSymbol,
wrapperForImpl,
implForWrapper,
tryWrapperForImpl,
Expand Down
Loading