Skip to content

Commit 5d1a96e

Browse files
committed
A bit better implementation
1 parent a27b44a commit 5d1a96e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/constructs/interface.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ ${this.name}PropertiesConstructor.prototype.constructor = ${this.name}Properties
4242

4343
this.str += `
4444
const ${this.name}Properties = new Proxy(${this.name}PropertiesConstructor.prototype, {
45+
defineProperty() {
46+
return false;
47+
},
48+
deleteProperty() {
49+
return false;
50+
},
4551
get(target, key) {
4652
if (key in this) {
4753
return this[key];
4854
}
4955
return target[key];
5056
},
51-
set(target, key, value) {
52-
this[key] = value;
53-
return true;
54-
}
5557
});\n\n`;
5658
};
5759

@@ -97,8 +99,7 @@ Interface.prototype.generateConstructor = function () {
9799
this.str += `${this.name}.prototype = Object.create(${this.idl.inheritance}.interface.prototype);
98100
${this.name}.prototype.constructor = ${this.name};\n`;
99101
} else if (utils.isGlobal(this.idl)) {
100-
this.str += `${this.name}.prototype = Object.create(${this.name}Properties);
101-
${this.name}.prototype.constructor = ${this.name};\n`;
102+
this.str += `Object.setPrototypeOf(${this.name}.prototype, ${this.name}Properties);\n`;
102103
}
103104
};
104105

0 commit comments

Comments
 (0)