Skip to content

Commit

Permalink
fix(vdom): svg inside foreignObject should be rendered with correct n…
Browse files Browse the repository at this point in the history
…amespace (fix vuejs#7330) (vuejs#7350)

* add failed test case

* fix failed test case

* fix(vdom): svg inside foreignObject should be rendered with correct namespace

* adjust comments
  • Loading branch information
javoski authored and aJean committed Aug 19, 2020
1 parent 1fc22ee commit 630b3bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/vdom/create-element.js
Expand Up @@ -139,7 +139,8 @@ function applyNS (vnode, ns, force) {
if (isDef(vnode.children)) {
for (let i = 0, l = vnode.children.length; i < l; i++) {
const child = vnode.children[i]
if (isDef(child.tag) && (isUndef(child.ns) || isTrue(force))) {
if (isDef(child.tag) && (
isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
applyNS(child, ns, force)
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/unit/modules/vdom/create-element.spec.js
Expand Up @@ -135,10 +135,12 @@ describe('create-element', () => {
it('render svg foreignObject with correct namespace', () => {
const vm = new Vue({})
const h = vm.$createElement
const vnode = h('svg', [h('foreignObject', [h('p')])])
const vnode = h('svg', [h('foreignObject', [h('p'), h('svg')])])
expect(vnode.ns).toBe('svg')
expect(vnode.children[0].ns).toBe('svg')
expect(vnode.children[0].children[0].ns).toBeUndefined()
// #7330
expect(vnode.children[0].children[1].ns).toBe('svg')
})

// #6642
Expand Down

0 comments on commit 630b3bf

Please sign in to comment.