@marcoms/make-element
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -92,2 +92,10 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
function convertToBoolAttr(val) { | ||
if (Boolean(val)) { | ||
return ''; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
function makeElement(def = {}) { | ||
@@ -129,5 +137,11 @@ const props = def.props || {}; | ||
} | ||
let boolAttr = false; | ||
if (typeof propDef.boolAttr === 'boolean') { | ||
boolAttr = propDef.boolAttr; | ||
} | ||
let toAttr = identity; | ||
if (typeof propDef.toAttr === 'function') { | ||
// this === element instance | ||
if (boolAttr) { | ||
toAttr = convertToBoolAttr; | ||
} | ||
else if (typeof propDef.toAttr === 'function') { | ||
toAttr = propDef.toAttr; | ||
@@ -156,2 +170,3 @@ } | ||
attr: attrName, | ||
boolAttr, | ||
// function used to produce an attribute value from a | ||
@@ -211,4 +226,9 @@ // property value | ||
internalAttr.needsPropagation = false; | ||
// invoke attributeChangedCallback | ||
this.setAttribute(attrName, attrVal); | ||
if (attrVal !== undefined) { | ||
// invoke attributeChangedCallback | ||
this.setAttribute(attrName, attrVal); | ||
} | ||
else { | ||
this.removeAttribute(attrName); | ||
} | ||
} | ||
@@ -215,0 +235,0 @@ internalProp.hasSet = true; |
{ | ||
"name": "@marcoms/make-element", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Create custom elements without boilerplate", | ||
@@ -5,0 +5,0 @@ "main": "build/make-element.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
133219
1192