From 5bf0faf3574a033b3d418e616492918658e87326 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 9 Feb 2015 23:23:00 -0500 Subject: [PATCH] #453 fix html entity order bug in m.trust --- mithril.js | 2 +- tests/e2e/tests.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index e02b3049..a2bc57d9 100644 --- a/mithril.js +++ b/mithril.js @@ -209,7 +209,7 @@ var m = (function app(window, undefined) { //fix offset of next element if item was a trusted string w/ more than one html element //the first clause in the regexp matches elements //the second clause (after the pipe) matches text nodes - subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || []).length + subArrayCount += (item.match(/<[^\/]|\>\s*[^<]|&/g) || []).length } else subArrayCount += type.call(item) === ARRAY ? item.length : 1; cached[cacheCount++] = item diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index ae1dff2a..7fb5183d 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -61,6 +61,14 @@ test('Mithril accessible as window.m', function() { ok(window.m) }) +test('m.trust w/ html entities', function() { + expect(1) + var view1 = m('div', "a", m.trust("&"), "b") + + m.render(dummyEl, view1) + equal(dummyEl.innerHTML, '
a&b
', 'view1 rendered correctly') +}) + test('array item removal', function() { expect(2) var view1 = m('div', {}, [