Use object lookup instead of long condition chain

This commit is contained in:
mar 2016-02-18 19:52:39 +00:00
parent 01ff1a36fd
commit 3f09713583

View file

@ -983,13 +983,13 @@
} }
} }
function shouldUseSetAttribute(attrName) { var shouldUseSetAttribute = {
return attrName !== "list" && list: 1,
attrName !== "style" && style: 1,
attrName !== "form" && form: 1,
attrName !== "type" && type: 1,
attrName !== "width" && width: 1,
attrName !== "height" height: 1
} }
function setSingleAttr( function setSingleAttr(
@ -1020,7 +1020,7 @@
attrName === "className" ? "class" : attrName, attrName === "className" ? "class" : attrName,
dataAttr) dataAttr)
} }
} else if (attrName in node && shouldUseSetAttribute(attrName)) { } else if (attrName in node && !shouldUseSetAttribute[attrName]) {
// handle cases that are properties (but ignore cases where we // handle cases that are properties (but ignore cases where we
// should use setAttribute instead) // should use setAttribute instead)
// //