mithril-node-render
Advanced tools
Comparing version 0.1.3 to 0.1.4
11
index.js
'use strict'; | ||
var VOID_TAGS = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', | ||
'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; | ||
function isArray(thing) { | ||
@@ -13,4 +16,4 @@ return Object.prototype.toString.call(thing) === '[object Array]'; | ||
function createAttrString(attrs) { | ||
if (!Object.keys(attrs).length) { | ||
return; | ||
if (!attrs || !Object.keys(attrs).length) { | ||
return ''; | ||
} | ||
@@ -65,4 +68,4 @@ | ||
var children = createChildrenContent(view); | ||
if (!children) { | ||
return ['<', view.tag, createAttrString(view.attrs), ' />'].join(''); | ||
if (!children && VOID_TAGS.indexOf(view.tag) >= 0) { | ||
return '<' + view.tag + createAttrString(view.attrs) + '>'; | ||
} | ||
@@ -69,0 +72,0 @@ return [ |
{ | ||
"name": "mithril-node-render", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Node rending of mithril views", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10
test.js
@@ -14,14 +14,14 @@ 'use strict'; | ||
'<div id="bar">content</div>', 'should render id'); | ||
t.equal(render(m('br')), '<br />', 'should render short nodes when no children'); | ||
t.equal(render(m('br')), '<br>', 'should render short nodes when no children'); | ||
t.equal(render(m('span', { | ||
'data-foo': 'bar', | ||
selected: 'selected' | ||
})), '<span data-foo="bar" selected="selected" />', 'should render attributes'); | ||
})), '<span data-foo="bar" selected="selected"></span>', 'should render attributes'); | ||
t.equal(render(m('ul', 'huhu')), '<ul>huhu</ul>', 'should render string'); | ||
t.equal(render([m('span', 'foo'), m('div', 'bar')]), | ||
'<span>foo</span><div>bar</div>', 'should render arrays'); | ||
t.equal(render(m('span', m('div'))), '<span><div /></span>', 'should render children'); | ||
t.equal(render(m('span', m('div'))), '<span><div></div></span>', 'should render children'); | ||
t.equal(render(m('span', { | ||
onmousemove: function(event) {} | ||
})), '<span />', 'should not render events'); | ||
})), '<span></span>', 'should not render events'); | ||
t.equal(render(m('span', { | ||
@@ -32,4 +32,4 @@ style: { | ||
} | ||
})), '<span style="padding-left:10px;color:red" />', 'should render children'); | ||
})), '<span style="padding-left:10px;color:red"></span>', 'should render children'); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
5072
5
96
1
15