From 974c048c274222e6036bad07358afc78db071481 Mon Sep 17 00:00:00 2001 From: Gregor Ihmor Date: Fri, 29 Apr 2022 14:07:33 +0200 Subject: [PATCH] Fix handling of (some) svg container elements Fixing issue #56 --- elements.js | 2 ++ test/index.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/elements.js b/elements.js index 048d37c..a5f7b40 100644 --- a/elements.js +++ b/elements.js @@ -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, diff --git a/test/index.js b/test/index.js index 9a0f68b..d434dc8 100644 --- a/test/index.js +++ b/test/index.js @@ -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 = '' + + t.equal(toHTML(vnode), htmlString) + + vnode = h('svg', [ + h('linearGradient', [ + h('stop') + ]) + ]) + htmlString = '' + t.equal(toHTML(vnode), htmlString) + + t.end() +})