diff --git a/compiler/generate/visitors/Element.js b/compiler/generate/visitors/Element.js index 69614e721f..6ffad9635d 100644 --- a/compiler/generate/visitors/Element.js +++ b/compiler/generate/visitors/Element.js @@ -13,7 +13,7 @@ export default { const local = { name, - namespace: name === 'svg' ? 'http://www.w3.org/2000/svg' : generator.current.namespace, + namespace: node.name === 'svg' ? 'http://www.w3.org/2000/svg' : generator.current.namespace, isComponent: false, allUsedContexts: new Set(), diff --git a/test/compiler/svg-multiple/_config.js b/test/compiler/svg-multiple/_config.js new file mode 100644 index 0000000000..9fd938e47a --- /dev/null +++ b/test/compiler/svg-multiple/_config.js @@ -0,0 +1,29 @@ +export default { + data: { + x: 0, + y: 0, + width: 100, + height: 100 + }, + + html: ` + + + `, + + test ( assert, component, target ) { + const svgs = target.querySelectorAll( 'svg' ); + const rects = target.querySelectorAll( 'rect' ); + + assert.equal( svgs[0].namespaceURI, 'http://www.w3.org/2000/svg' ); + assert.equal( svgs[0].namespaceURI, 'http://www.w3.org/2000/svg' ); + assert.equal( rects[1].namespaceURI, 'http://www.w3.org/2000/svg' ); + assert.equal( rects[1].namespaceURI, 'http://www.w3.org/2000/svg' ); + + component.set({ width: 150, height: 50 }); + assert.htmlEqual( target.innerHTML, ` + + + ` ); + } +}; diff --git a/test/compiler/svg-multiple/main.html b/test/compiler/svg-multiple/main.html new file mode 100644 index 0000000000..2998701d4b --- /dev/null +++ b/test/compiler/svg-multiple/main.html @@ -0,0 +1,7 @@ + + + + + + +