mithril-node-render
Advanced tools
Comparing version 0.4.2 to 0.5.0
14
index.js
@@ -35,3 +35,5 @@ 'use strict'; | ||
function createAttrString(attrs, escapeAttributeValue) { | ||
function createAttrString(view, escapeAttributeValue) { | ||
var attrs = view.attrs; | ||
if (!attrs || !Object.keys(attrs).length) { | ||
@@ -61,2 +63,8 @@ return ''; | ||
} | ||
// Handle SVG <use> tags specially | ||
if (name === 'href' && view.tag === 'use') { | ||
return ' xlink:href="' + escapeAttributeValue(value, true) + '"'; | ||
} | ||
return ' ' + (name === 'className' ? 'class' : name) + '="' + escapeAttributeValue(value, true) + '"'; | ||
@@ -119,6 +127,6 @@ }).join(''); | ||
if (!children && VOID_TAGS.indexOf(view.tag.toLowerCase()) >= 0) { | ||
return '<' + view.tag + createAttrString(view.attrs, options.escapeAttributeValue) + '>'; | ||
return '<' + view.tag + createAttrString(view, options.escapeAttributeValue) + '>'; | ||
} | ||
return [ | ||
'<', view.tag, createAttrString(view.attrs, options.escapeAttributeValue), '>', | ||
'<', view.tag, createAttrString(view, options.escapeAttributeValue), '>', | ||
children, | ||
@@ -125,0 +133,0 @@ '</', view.tag, '>', |
{ | ||
"name": "mithril-node-render", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Node rending of mithril views", | ||
@@ -26,5 +26,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mithril": "0.2.2-rc.1", | ||
"tape": "4.4.0" | ||
"mithril": "0.2.4", | ||
"tape": "4.5.1" | ||
} | ||
} |
@@ -63,2 +63,3 @@ 'use strict'; | ||
t.equal(render(m('pre', 'var = ' + JSON.stringify({foo: 1}))), '<pre>var = {"foo":1}</pre>'); | ||
t.equal(render(m('svg', m('use', { href : "fooga.com" }))), '<svg><use xlink:href="fooga.com"></use></svg>'); | ||
t.end(); | ||
@@ -65,0 +66,0 @@ }); |
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
11131
216