Skip to content

Commit

Permalink
add better falsy values, and fix setting attributes for xlink:href (f…
Browse files Browse the repository at this point in the history
…ixes #31)
  • Loading branch information
kbrsh committed Apr 14, 2017
1 parent 99ac4c8 commit 9b90318
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,19 @@
var vnodePropValue = vnodeProps[vnodePropName];
var nodePropValue = nodeProps[vnodePropName];

if (vnodePropValue !== false && (nodePropValue == null || vnodePropValue !== nodePropValue)) {
node.setAttribute(vnodePropName, vnodePropValue === true ? '' : vnodePropValue);
if ((vnodePropValue !== undefined || vnodePropValue !== false || vnodePropValue !== null) && (nodePropValue === undefined || nodePropValue === false || nodePropValue === null || vnodePropValue !== nodePropValue)) {
if (vnodePropName.length === 10 && vnodePropName === "xlink:href") {
node.setAttributeNS('http://www.w3.org/1999/xlink', "href", vnodePropValue);
} else {
node.setAttribute(vnodePropName, vnodePropValue === true ? '' : vnodePropValue);
}
}
}

// Diff Node Props with VNode Props
for (var nodePropName in nodeProps) {
var _vnodePropValue = vnodeProps[nodePropName];
if (_vnodePropValue === undefined || _vnodePropValue === false) {
if (_vnodePropValue === undefined || _vnodePropValue === false || _vnodePropValue === null) {
node.removeAttribute(nodePropName);
}
}
Expand Down
Loading

0 comments on commit 9b90318

Please sign in to comment.