Skip to content

Commit 0c942f0

Browse files
sto3pslyyx990803
authored andcommitted
ElementNamespace
1 parent ef85636 commit 0c942f0

File tree

12 files changed

+70
-58
lines changed

12 files changed

+70
-58
lines changed

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ComponentPublicInstance
1717
} from './componentPublicInstance'
1818
import { Directive, validateDirectiveName } from './directives'
19-
import { RootRenderFunction } from './renderer'
19+
import { ElementNamespace, RootRenderFunction } from './renderer'
2020
import { InjectionKey } from './apiInject'
2121
import { warn } from './warning'
2222
import { createVNode, cloneVNode, VNode } from './vnode'
@@ -47,7 +47,7 @@ export interface App<HostElement = any> {
4747
mount(
4848
rootContainer: HostElement | string,
4949
isHydrate?: boolean,
50-
namespace?: 'svg' | 'mathml'
50+
namespace?: ElementNamespace
5151
): ComponentPublicInstance
5252
unmount(): void
5353
provide<T>(key: InjectionKey<T> | string, value: T): this

packages/runtime-core/src/compat/global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@vue/shared'
1818
import { warn } from '../warning'
1919
import { cloneVNode, createVNode } from '../vnode'
20-
import { RootRenderFunction } from '../renderer'
20+
import { ElementNamespace, RootRenderFunction } from '../renderer'
2121
import {
2222
App,
2323
AppConfig,
@@ -503,7 +503,7 @@ function installCompatMount(
503503
container = selectorOrEl || document.createElement('div')
504504
}
505505

506-
let namespace: 'svg' | 'mathml' | undefined
506+
let namespace: ElementNamespace
507507
if (container instanceof SVGElement) namespace = 'svg'
508508
else if (container instanceof MathMLElement) namespace = 'mathml'
509509

packages/runtime-core/src/components/KeepAlive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
queuePostRenderEffect,
3838
MoveType,
3939
RendererElement,
40-
RendererNode
40+
RendererNode,
41+
ElementNamespace
4142
} from '../renderer'
4243
import { setTransitionHooks } from './BaseTransition'
4344
import { ComponentRenderContext } from '../componentPublicInstance'
@@ -64,7 +65,7 @@ export interface KeepAliveContext extends ComponentRenderContext {
6465
vnode: VNode,
6566
container: RendererElement,
6667
anchor: RendererNode | null,
67-
namespace: 'svg' | 'mathml' | undefined,
68+
namespace: ElementNamespace,
6869
optimized: boolean
6970
) => void
7071
deactivate: (vnode: VNode) => void

packages/runtime-core/src/components/Suspense.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
MoveType,
1919
SetupRenderEffectFn,
2020
RendererNode,
21-
RendererElement
21+
RendererElement,
22+
ElementNamespace
2223
} from '../renderer'
2324
import { queuePostFlushCb } from '../scheduler'
2425
import { filterSingleRoot, updateHOCHostEl } from '../componentRenderUtils'
@@ -63,7 +64,7 @@ export const SuspenseImpl = {
6364
anchor: RendererNode | null,
6465
parentComponent: ComponentInternalInstance | null,
6566
parentSuspense: SuspenseBoundary | null,
66-
namespace: 'svg' | 'mathml' | undefined,
67+
namespace: ElementNamespace,
6768
slotScopeIds: string[] | null,
6869
optimized: boolean,
6970
// platform-specific impl passed from renderer
@@ -130,7 +131,7 @@ function mountSuspense(
130131
anchor: RendererNode | null,
131132
parentComponent: ComponentInternalInstance | null,
132133
parentSuspense: SuspenseBoundary | null,
133-
namespace: 'svg' | 'mathml' | undefined,
134+
namespace: ElementNamespace,
134135
slotScopeIds: string[] | null,
135136
optimized: boolean,
136137
rendererInternals: RendererInternals
@@ -195,7 +196,7 @@ function patchSuspense(
195196
container: RendererElement,
196197
anchor: RendererNode | null,
197198
parentComponent: ComponentInternalInstance | null,
198-
namespace: 'svg' | 'mathml' | undefined,
199+
namespace: ElementNamespace,
199200
slotScopeIds: string[] | null,
200201
optimized: boolean,
201202
{ p: patch, um: unmount, o: { createElement } }: RendererInternals
@@ -376,7 +377,7 @@ export interface SuspenseBoundary {
376377
vnode: VNode<RendererNode, RendererElement, SuspenseProps>
377378
parent: SuspenseBoundary | null
378379
parentComponent: ComponentInternalInstance | null
379-
namespace: 'svg' | 'mathml' | undefined
380+
namespace: ElementNamespace
380381
container: RendererElement
381382
hiddenContainer: RendererElement
382383
anchor: RendererNode | null
@@ -413,7 +414,7 @@ function createSuspenseBoundary(
413414
container: RendererElement,
414415
hiddenContainer: RendererElement,
415416
anchor: RendererNode | null,
416-
namespace: 'svg' | 'mathml' | undefined,
417+
namespace: ElementNamespace,
417418
slotScopeIds: string[] | null,
418419
optimized: boolean,
419420
rendererInternals: RendererInternals,
@@ -721,7 +722,7 @@ function hydrateSuspense(
721722
vnode: VNode,
722723
parentComponent: ComponentInternalInstance | null,
723724
parentSuspense: SuspenseBoundary | null,
724-
namespace: 'svg' | 'mathml' | undefined,
725+
namespace: ElementNamespace,
725726
slotScopeIds: string[] | null,
726727
optimized: boolean,
727728
rendererInternals: RendererInternals,

packages/runtime-core/src/components/Teleport.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
RendererElement,
77
RendererNode,
88
RendererOptions,
9-
traverseStaticChildren
9+
traverseStaticChildren,
10+
ElementNamespace
1011
} from '../renderer'
1112
import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
1213
import { isString, ShapeFlags } from '@vue/shared'
@@ -75,7 +76,7 @@ export const TeleportImpl = {
7576
anchor: RendererNode | null,
7677
parentComponent: ComponentInternalInstance | null,
7778
parentSuspense: SuspenseBoundary | null,
78-
namespace: 'svg' | 'mathml' | undefined,
79+
namespace: ElementNamespace,
7980
slotScopeIds: string[] | null,
8081
optimized: boolean,
8182
internals: RendererInternals
@@ -112,7 +113,7 @@ export const TeleportImpl = {
112113
if (target) {
113114
insert(targetAnchor, target)
114115
// #2652 we could be teleporting from a non-SVG tree into an SVG tree
115-
if (namespace === 'svg' || isTargetSVG(target)) {
116+
if (namespace === true || namespace === 'svg' || isTargetSVG(target)) {
116117
namespace = 'svg'
117118
}
118119
if (namespace === 'mathml' || isTargetMathML(target)) {
@@ -154,7 +155,7 @@ export const TeleportImpl = {
154155
const currentContainer = wasDisabled ? container : target
155156
const currentAnchor = wasDisabled ? mainAnchor : targetAnchor
156157

157-
if (namespace === 'svg' || isTargetSVG(target)) {
158+
if (namespace === true || namespace === 'svg' || isTargetSVG(target)) {
158159
namespace = 'svg'
159160
}
160161
if (namespace === 'mathml' || isTargetMathML(target)) {

packages/runtime-core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ export type {
260260
RendererElement,
261261
HydrationRenderer,
262262
RendererOptions,
263-
RootRenderFunction
263+
RootRenderFunction,
264+
ElementNamespace
264265
} from './renderer'
265266
export type { RootHydrateFunction } from './hydration'
266267
export type { Slot, Slots, SlotsType } from './componentSlots'

0 commit comments

Comments
 (0)