#453 fix html entity order bug in m.trust

This commit is contained in:
Leo Horie 2015-02-09 23:23:00 -05:00
parent 2fa4632186
commit 5bf0faf357
2 changed files with 9 additions and 1 deletions

View file

@ -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

View file

@ -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("&amp;"), "b")
m.render(dummyEl, view1)
equal(dummyEl.innerHTML, '<div>a&amp;b</div>', 'view1 rendered correctly')
})
test('array item removal', function() {
expect(2)
var view1 = m('div', {}, [