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 #7330) (#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 yyx990803 committed Jan 5, 2018
1 parent 6ee6849 commit 0529961
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 0529961

Please sign in to comment.