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) {
return attrName !== "list" &&
attrName !== "style" &&
attrName !== "form" &&
attrName !== "type" &&
attrName !== "width" &&
attrName !== "height"
var shouldUseSetAttribute = {
list: 1,
style: 1,
form: 1,
type: 1,
width: 1,
height: 1
}
function setSingleAttr(
@ -1020,7 +1020,7 @@
attrName === "className" ? "class" : attrName,
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
// should use setAttribute instead)
//