Reputation: 560
Is there a way to add svg attributes to nodes using virtual-hyperscript in virtual dom? For example, something like this:
var h = require('virtual-dom/h')
h('svg', [
h('circle', {cx: 100, cy: 100}, 'some text')
])
I've tried to do this myself, but the attributes are removed on create
.
Upvotes: 0
Views: 848
Reputation: 560
Turns out you do this:
h('circle', {namespace: "http://www.w3.org/2000/svg", attributes: {cx: 100}})
createElement
and createElementNS
as two different things even though they output the same html. Namespace is needed to differentiate it from a normal DOM element.See: https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript#namespace
Upvotes: 2