From 886d796e0b020c7cc02dc59f657c992aed0e54ca Mon Sep 17 00:00:00 2001 From: Joshua Kifer Date: Tue, 5 Jan 2016 11:53:01 -0800 Subject: [PATCH] Fixed setAttributes for custom components (like Polymer uses) with readonly properties --- mithril.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index 2e1153bb..c6384beb 100644 --- a/mithril.js +++ b/mithril.js @@ -579,7 +579,11 @@ var m = (function app(window, undefined) { //- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js else if (attrName in node && attrName !== "list" && attrName !== "style" && attrName !== "form" && attrName !== "type" && attrName !== "width" && attrName !== "height") { //#348 don't set the value if not needed otherwise cursor placement breaks in Chrome - if (tag !== "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr; + try { + if (tag !== "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr; + } catch (e) { + node.setAttribute(attrName, dataAttr); + } } else node.setAttribute(attrName, dataAttr); }