Use object lookup instead of long condition chain
This commit is contained in:
parent
01ff1a36fd
commit
3f09713583
1 changed files with 8 additions and 8 deletions
16
mithril.js
16
mithril.js
|
|
@ -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)
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue