diff --git a/lib/browser/common/util/dom.js b/lib/browser/common/util/dom.js index e2cfc38612..a79e61aac0 100644 --- a/lib/browser/common/util/dom.js +++ b/lib/browser/common/util/dom.js @@ -38,12 +38,13 @@ export function createDOMPlaceholder() { } /** - * Check if a DOM node is an svg tag + * Check if a DOM node is an svg tag or part of an svg * @param { HTMLElement } el - node we want to test * @returns {Boolean} true if it's an svg node */ export function isSvg(el) { - return !!el.ownerSVGElement + const owner = el.ownerSVGElement + return !!owner || owner === null } /** diff --git a/test/specs/browser/riot/each-no-keys.spec.js b/test/specs/browser/riot/each-no-keys.spec.js index 8637eef508..d57849a277 100644 --- a/test/specs/browser/riot/each-no-keys.spec.js +++ b/test/specs/browser/riot/each-no-keys.spec.js @@ -85,8 +85,9 @@ describe('Riot each not keyed', function() { const tag = riot.mount('loop-svg-nodes')[0] - expect($$('svg circle', tag.root).length).to.be.equal(3) + expect($$('svg circle', tag.root).length).to.be.equal(5) expect($('svg circle', tag.root) instanceof HTMLElement).to.be.equal(false) + expect($('svg .nested-circle', tag.root) instanceof HTMLElement).to.be.equal(false) expect($('p', tag.root) instanceof HTMLElement).to.be.equal(true) tag.unmount() diff --git a/test/specs/server/index.js b/test/specs/server/index.js index 90edf5d045..700373bc19 100644 --- a/test/specs/server/index.js +++ b/test/specs/server/index.js @@ -109,7 +109,7 @@ describe('Node', function() { it('render tag: svg loops', function() { var svg = riot.render('loop-svg-nodes') var $ = cheerio.load(svg) - expect($('circle').length).to.be.equal(3) + expect($('circle').length).to.be.equal(5) }) it('render tag: loops having conditional directives', function() { diff --git a/test/tag/loop-svg-nodes.tag b/test/tag/loop-svg-nodes.tag index 2e0acd3d14..50e19f1bee 100644 --- a/test/tag/loop-svg-nodes.tag +++ b/test/tag/loop-svg-nodes.tag @@ -1,9 +1,22 @@ +

Description

this.points = [{'x': 1,'y': 0}, {'x': 9, 'y': 6}, {'x': 4, 'y': 7}] + this.circles = [ + {'x': 40, 'y': 20, 'fill': 'red'}, + {'x': 60, 'y': 20, 'fill': 'yellow'}, + ] +
- \ No newline at end of file + + + \ No newline at end of file