diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js index cc041a75..32b46807 100644 --- a/src/core/vdom/create-element.js +++ b/src/core/vdom/create-element.js @@ -71,7 +71,6 @@ export function _createElement ( // unknown or unlisted namespaced elements // check at runtime because it may get assigned a namespace when its // parent normalizes children - ns = tag === 'foreignObject' ? 'xhtml' : ns vnode = new VNode( tag, data, children, undefined, undefined, context @@ -91,6 +90,10 @@ export function _createElement ( function applyNS (vnode, ns) { vnode.ns = ns + if (vnode.tag === 'foreignObject') { + // use default namespace inside foreignObject + return + } if (vnode.children) { for (let i = 0, l = vnode.children.length; i < l; i++) { const child = vnode.children[i] diff --git a/src/platforms/web/util/element.js b/src/platforms/web/util/element.js index e0f91294..8e69c7d1 100644 --- a/src/platforms/web/util/element.js +++ b/src/platforms/web/util/element.js @@ -5,8 +5,7 @@ import { makeMap } from 'shared/util' export const namespaceMap = { svg: 'http://www.w3.org/2000/svg', - math: 'http://www.w3.org/1998/Math/MathML', - xhtml: 'http://www.w3.org/1999/xhtml' + math: 'http://www.w3.org/1998/Math/MathML' } export const isHTMLTag = makeMap( diff --git a/test/unit/modules/vdom/create-element.spec.js b/test/unit/modules/vdom/create-element.spec.js index a08c680a..f937cbc5 100644 --- a/test/unit/modules/vdom/create-element.spec.js +++ b/test/unit/modules/vdom/create-element.spec.js @@ -132,6 +132,15 @@ describe('create-element', () => { expect(vnode.children[0].componentOptions).toBeUndefined() }) + it('render svg foreignObject with correct namespace', () => { + const vm = new Vue({}) + const h = vm.$createElement + const vnode = h('svg', [h('foreignObject', [h('p')])]) + expect(vnode.ns).toBe('svg') + expect(vnode.children[0].ns).toBe('svg') + expect(vnode.children[0].children[0].ns).toBeUndefined() + }) + it('warn observed data objects', () => { new Vue({ data: {