mimic html fallback-to-doing-nothing-on-invalid-attributes behavior in IE8, instead of throwing non-helpful "Invalid argument." error
This commit is contained in:
parent
8285b903d6
commit
0ee2d7f200
1 changed files with 25 additions and 19 deletions
|
|
@ -277,6 +277,7 @@ Mithril = m = new function app(window, undefined) {
|
|||
var cachedAttr = cachedAttrs[attrName]
|
||||
if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) {
|
||||
cachedAttrs[attrName] = dataAttr
|
||||
try {
|
||||
if (attrName === "config") continue
|
||||
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
|
||||
node[attrName] = autoredraw(dataAttr, node)
|
||||
|
|
@ -302,6 +303,11 @@ Mithril = m = new function app(window, undefined) {
|
|||
}
|
||||
else node.setAttribute(attrName, dataAttr)
|
||||
}
|
||||
catch (e) {
|
||||
//swallow IE's invalid argument errors to mimic HTML's fallback-to-doing-nothing-on-invalid-attributes behavior
|
||||
if (e.message.indexOf("Invalid argument") < 0) throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
return cachedAttrs
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue