Comparing version 0.6.5 to 0.6.6
{ | ||
"typescript.check.workspaceVersion": false | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
function updateAttrs(oldVnode, vnode) { | ||
var key, cur, old, elm = vnode.elm, oldAttrs = oldVnode.data.attrs, attrs = vnode.data.attrs, namespaceSplit; | ||
var key, elm = vnode.elm, oldAttrs = oldVnode.data.attrs, attrs = vnode.data.attrs, namespaceSplit; | ||
if (!oldAttrs && !attrs) | ||
@@ -26,17 +26,25 @@ return; | ||
for (key in attrs) { | ||
cur = attrs[key]; | ||
old = oldAttrs[key]; | ||
var cur = attrs[key]; | ||
var old = oldAttrs[key]; | ||
if (old !== cur) { | ||
if (!cur && booleanAttrsDict[key]) | ||
elm.removeAttribute(key); | ||
if (booleanAttrsDict[key]) { | ||
if (cur) { | ||
elm.setAttribute(key, ""); | ||
} | ||
else { | ||
elm.removeAttribute(key); | ||
} | ||
} | ||
else { | ||
namespaceSplit = key.split(":"); | ||
if (namespaceSplit.length > 1 && NamespaceURIs.hasOwnProperty(namespaceSplit[0])) | ||
if (namespaceSplit.length > 1 && NamespaceURIs.hasOwnProperty(namespaceSplit[0])) { | ||
elm.setAttributeNS(NamespaceURIs[namespaceSplit[0]], key, cur); | ||
else | ||
} | ||
else { | ||
elm.setAttribute(key, cur); | ||
} | ||
} | ||
} | ||
} | ||
//remove removed attributes | ||
// remove removed attributes | ||
// use `in` operator since the previous `for` iteration uses it (.i.e. add even attributes with undefined value) | ||
@@ -43,0 +51,0 @@ // the other option is to remove all attributes with value == undefined |
{ | ||
"name": "snabbdom", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.", | ||
@@ -5,0 +5,0 @@ "main": "snabbdom.js", |
@@ -15,3 +15,4 @@ import {VNode, VNodeData} from '../vnode'; | ||
const booleanAttrsDict = Object.create(null); | ||
const booleanAttrsDict: {[attribute: string]: boolean} = Object.create(null); | ||
for (let i = 0, len = booleanAttrs.length; i < len; i++) { | ||
@@ -22,3 +23,3 @@ booleanAttrsDict[booleanAttrs[i]] = true; | ||
function updateAttrs(oldVnode: VNode, vnode: VNode): void { | ||
var key: string, cur: any, old: any, elm: Element = vnode.elm as Element, | ||
var key: string, elm: Element = vnode.elm as Element, | ||
oldAttrs = (oldVnode.data as VNodeData).attrs, | ||
@@ -34,17 +35,22 @@ attrs = (vnode.data as VNodeData).attrs, namespaceSplit: Array<string>; | ||
for (key in attrs) { | ||
cur = attrs[key]; | ||
old = oldAttrs[key]; | ||
const cur = attrs[key]; | ||
const old = oldAttrs[key]; | ||
if (old !== cur) { | ||
if (!cur && booleanAttrsDict[key]) | ||
elm.removeAttribute(key); | ||
else { | ||
if (booleanAttrsDict[key]) { | ||
if (cur) { | ||
elm.setAttribute(key, ""); | ||
} else { | ||
elm.removeAttribute(key); | ||
} | ||
} else { | ||
namespaceSplit = key.split(":"); | ||
if (namespaceSplit.length > 1 && NamespaceURIs.hasOwnProperty(namespaceSplit[0])) | ||
if (namespaceSplit.length > 1 && NamespaceURIs.hasOwnProperty(namespaceSplit[0])) { | ||
elm.setAttributeNS((NamespaceURIs as any)[namespaceSplit[0]], key, cur); | ||
else | ||
} else { | ||
elm.setAttribute(key, cur); | ||
} | ||
} | ||
} | ||
} | ||
//remove removed attributes | ||
// remove removed attributes | ||
// use `in` operator since the previous `for` iteration uses it (.i.e. add even attributes with undefined value) | ||
@@ -51,0 +57,0 @@ // the other option is to remove all attributes with value == undefined |
Sorry, the diff of this file is not supported yet
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
1022445
16046
127
1