Comparing version 4.0.2 to 4.1.0
@@ -13,2 +13,9 @@ "use strict"; | ||
if (idlType.nullable) { | ||
str += ` | ||
if (${name} === null || ${name} === undefined) { | ||
${name} = null; | ||
} else {`; | ||
} | ||
if (conversions[idlType.idlType] || customTypes.has(idlType.idlType)) { | ||
@@ -27,9 +34,2 @@ const enforceRange = utils.getExtAttr(argAttrs, "EnforceRange"); | ||
} | ||
if (idlType.nullable) { | ||
str += ` | ||
if (${name} === null || ${name} === undefined) { | ||
${name} = null; | ||
} else {`; | ||
} | ||
let conversionFn = null; | ||
@@ -59,7 +59,7 @@ if (conversions[idlType.idlType]) { | ||
} | ||
} | ||
if (idlType.nullable) { | ||
str += ` | ||
if (idlType.nullable) { | ||
str += ` | ||
}`; | ||
} | ||
} | ||
@@ -66,0 +66,0 @@ |
@@ -26,12 +26,21 @@ "use strict"; | ||
["long", "unsigned long"].forEach((key) => { | ||
module.exports[key] = { | ||
get(objName, attrName) { | ||
return `const value = this.getAttribute("${attrName}"); | ||
return value === null ? "" : String(value);`; | ||
}, | ||
set(objName, attrName) { | ||
return `this.setAttribute("${attrName}", String(V));`; | ||
} | ||
}; | ||
}); | ||
module.exports["long"] = { | ||
get(objName, attrName) { | ||
return `const value = parseInt(this.getAttribute("${attrName}")); | ||
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value`; | ||
}, | ||
set(objName, attrName) { | ||
return `this.setAttribute("${attrName}", String(V));`; | ||
} | ||
}; | ||
module.exports["unsigned long"] = { | ||
get(objName, attrName) { | ||
return `const value = parseInt(this.getAttribute("${attrName}")); | ||
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value`; | ||
}, | ||
set(objName, attrName) { | ||
return `V = V > 2147483647 ? 0 : V; | ||
this.setAttribute("${attrName}", String(V));`; | ||
} | ||
}; |
{ | ||
"name": "webidl2js", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "Auto-generates class structures for WebIDL specifications", | ||
@@ -5,0 +5,0 @@ "main": "index.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
32114
936