Skip to content

Commit

Permalink
A bit better implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebmaster committed May 22, 2016
1 parent 48ccbe2 commit c6e320e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ ${this.name}PropertiesConstructor.prototype.constructor = ${this.name}Properties

this.str += `
const ${this.name}Properties = new Proxy(${this.name}PropertiesConstructor.prototype, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(target, key) {
if (key in this) {
return this[key];
}
return target[key];
},
set(target, key, value) {
this[key] = value;
return true;
}
});\n\n`;
};

Expand Down Expand Up @@ -97,8 +99,7 @@ Interface.prototype.generateConstructor = function () {
this.str += `${this.name}.prototype = Object.create(${this.idl.inheritance}.interface.prototype);
${this.name}.prototype.constructor = ${this.name};\n`;
} else if (utils.isGlobal(this.idl)) {
this.str += `${this.name}.prototype = Object.create(${this.name}Properties);
${this.name}.prototype.constructor = ${this.name};\n`;
this.str += `Object.setPrototypeOf(${this.name}.prototype, ${this.name}Properties);\n`;
}
};

Expand Down

0 comments on commit c6e320e

Please sign in to comment.