From c1dc8d89ee8819f82def0c96251d18ea7af38b31 Mon Sep 17 00:00:00 2001
From: BeiYuShuiGuoLvDeKongQi <958414905@qq.com>
Date: Sun, 26 Apr 2020 21:38:53 +0800
Subject: [PATCH] fix(namespace): apply every namespace in slot when call
applyNS (#11315)
---
src/core/vdom/create-element.js | 11 +++++
test/unit/modules/vdom/create-element.spec.js | 43 +++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js
index ba36e15b12d..f8bb5f0413a 100644
--- a/src/core/vdom/create-element.js
+++ b/src/core/vdom/create-element.js
@@ -151,6 +151,17 @@ function applyNS (vnode, ns, force) {
}
}
}
+
+ // #11315
+ if (isObject(vnode.componentOptions) && isDef(vnode.componentOptions.children)) {
+ for (var i = 0, l = vnode.componentOptions.children.length; i < l; i++) {
+ var child = vnode.componentOptions.children[i]
+ if (isDef(child.tag) && (
+ isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
+ applyNS(child, ns, force)
+ }
+ }
+ }
}
// ref #5318
diff --git a/test/unit/modules/vdom/create-element.spec.js b/test/unit/modules/vdom/create-element.spec.js
index 68773850be7..1212cdc95ff 100644
--- a/test/unit/modules/vdom/create-element.spec.js
+++ b/test/unit/modules/vdom/create-element.spec.js
@@ -143,6 +143,49 @@ describe('create-element', () => {
expect(vnode.children[0].children[1].ns).toBe('svg')
})
+ // #11315
+ it('render svg foreignObject nested component slot with correct namespace', () => {
+ const vm = new Vue({
+ template: `
+
+ `,
+ components: {
+ 'box': {
+ template: `
+