From 75567c68cc4f8e6053ef8d767a8cb04dc09a1b54 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 17 Nov 2014 23:03:13 -0500 Subject: [PATCH] don't break input cursor in chrome --- mithril.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mithril.js b/mithril.js index db22d811..19dd41b9 100644 --- a/mithril.js +++ b/mithril.js @@ -343,7 +343,8 @@ Mithril = m = new function app(window, undefined) { //- list and form are typically used as strings, but are DOM element references in js //- 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")) { - node[attrName] = dataAttr + //#348 don't set the value if not needed otherwise cursor placement breaks in Chrome + if (node[attrName] != dataAttr) node[attrName] = dataAttr } else node.setAttribute(attrName, dataAttr) } @@ -352,7 +353,8 @@ Mithril = m = new function app(window, undefined) { if (e.message.indexOf("Invalid argument") < 0) throw e } } - else if (attrName === "value" && tag === "input" && node.value !== dataAttr) { + //#348 dataAttr may not be a string, so use loose comparison (double equal) instead of strict (triple equal) + else if (attrName === "value" && tag === "input" && node.value != dataAttr) { node.value = dataAttr } }