Comparing version 6.0.3 to 6.1.0
@@ -21,2 +21,3 @@ "use strict"; | ||
const shouldReflect = utils.getExtAttr(this.idl.extAttrs, "Reflect"); | ||
const sameObject = utils.getExtAttr(this.idl.extAttrs, "SameObject"); | ||
@@ -48,2 +49,6 @@ let objName = `this`; | ||
if (sameObject) { | ||
getterBody = `return utils.getSameObject(this, "${this.idl.name}", () => { ${getterBody} });`; | ||
} | ||
str += `Object.defineProperty(${definedOn}, "${this.idl.name}", { | ||
@@ -50,0 +55,0 @@ get() { |
@@ -16,3 +16,16 @@ "use strict"; | ||
const implSymbol = Symbol("impl"); | ||
const sameObjectCaches = Symbol("SameObject caches"); | ||
function getSameObject(wrapper, prop, creator) { | ||
if (!wrapper[sameObjectCaches]) { | ||
wrapper[sameObjectCaches] = Object.create(null); | ||
} | ||
if (prop in wrapper[sameObjectCaches]) { | ||
return wrapper[sameObjectCaches][prop]; | ||
} | ||
return wrapper[sameObjectCaches][prop] = creator(); | ||
} | ||
function wrapperForImpl(impl) { | ||
@@ -41,2 +54,3 @@ return impl ? impl[wrapperSymbol] : null; | ||
module.exports.implSymbol = implSymbol; | ||
module.exports.getSameObject = getSameObject; | ||
module.exports.wrapperForImpl = wrapperForImpl; | ||
@@ -43,0 +57,0 @@ module.exports.implForWrapper = implForWrapper; |
{ | ||
"name": "webidl2js", | ||
"version": "6.0.3", | ||
"version": "6.1.0", | ||
"description": "Auto-generates class structures for WebIDL specifications", | ||
@@ -5,0 +5,0 @@ "main": "lib/transformer.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41406
1209