Skip to content

Commit

Permalink
Merge pull request #64 from gregor-i/master
Browse files Browse the repository at this point in the history
Fix handling of (some) svg container elements
  • Loading branch information
acstll authored Apr 29, 2022
2 parents 6d5730f + 974c048 commit 831b62a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ exports.CONTAINER = {
'switch': true,
'symbol': true,
'text': true,
'clipPath': true,
'linearGradient': true,

// http://www.w3.org/TR/SVG/intro.html#TermDescriptiveElement
'desc': true,
Expand Down
20 changes: 20 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,23 @@ test('Boolean attributes', function (t) {

t.end()
})

test('svg container elements', function (t) {
var vnode = h('svg',
{ attrs: { xmlns: 'http://www.w3.org/2000/svg' } },
[h('defs', [h('clipPath', [h('rect', { attrs: { x: 0, y: 1, width: 2, height: 3 } })])])]
)
var htmlString = '<svg xmlns="http://www.w3.org/2000/svg"><defs><clipPath><rect x="0" y="1" width="2" height="3" /></clipPath></defs></svg>'

t.equal(toHTML(vnode), htmlString)

vnode = h('svg', [
h('linearGradient', [
h('stop')
])
])
htmlString = '<svg><linearGradient><stop /></linearGradient></svg>'
t.equal(toHTML(vnode), htmlString)

t.end()
})

0 comments on commit 831b62a

Please sign in to comment.