Răsfoiți Sursa

fix: inherit SVG ns on component root node (#6511)

fix #6506
AchillesJ 8 ani în urmă
părinte
comite
89f0d29f2d

+ 1 - 1
src/core/vdom/create-element.js

@@ -91,7 +91,7 @@ export function _createElement (
   let vnode, ns
   if (typeof tag === 'string') {
     let Ctor
-    ns = config.getTagNamespace(tag)
+    ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag)
     if (config.isReservedTag(tag)) {
       // platform built-in elements
       vnode = new VNode(

+ 18 - 0
test/unit/modules/vdom/create-element.spec.js

@@ -141,6 +141,24 @@ describe('create-element', () => {
     expect(vnode.children[0].children[0].ns).toBeUndefined()
   })
 
+  // #6506
+  it('render SVGAElement in a component correctly', () => {
+    const vm = new Vue({
+      template: `
+        <svg>
+          <test></test>
+        </svg>
+      `,
+      components: {
+        test: { render: h => h('a') }
+      }
+    }).$mount()
+    const testComp = vm.$children[0]
+    expect(testComp.$vnode.ns).toBe('svg')
+    expect(testComp._vnode.tag).toBe('a')
+    expect(testComp._vnode.ns).toBe('svg')
+  })
+
   it('warn observed data objects', () => {
     new Vue({
       data: {