Skip to content

Commit 5f375c5

Browse files
committed
feat: allow opting out of stubbed transitions
1 parent 42d4b61 commit 5f375c5

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { ComponentPublicInstance } from 'vue'
12
import { GlobalMountOptions } from './types'
23
import { VueWrapper } from './vueWrapper'
3-
import { ComponentPublicInstance } from 'vue'
44

55
interface GlobalConfigOptions {
66
global: GlobalMountOptions
@@ -19,7 +19,7 @@ interface Plugin {
1919
}
2020

2121
class Pluggable {
22-
installedPlugins = [] as Array<Plugin>
22+
installedPlugins: Plugin[] = []
2323

2424
install(
2525
handler: (
@@ -55,7 +55,12 @@ class Pluggable {
5555
}
5656

5757
export const config: GlobalConfigOptions = {
58-
global: {},
58+
global: {
59+
stubs: {
60+
transition: true,
61+
'transition-group': true
62+
}
63+
},
5964
plugins: {
6065
VueWrapper: new Pluggable(),
6166
DOMWrapper: new Pluggable()

src/mount.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,9 @@ export function mount(
350350
app.mixin(attachEmitListener())
351351

352352
// stubs
353-
if (global.stubs || options?.shallow) {
354-
stubComponents(global.stubs, options?.shallow)
355-
} else {
356-
// still apply default stub of Transition and Transition Group
357-
stubComponents()
358-
}
353+
// even if we are using `mount`, we will still
354+
// stub out Transition and Transition Group by default.
355+
stubComponents(global.stubs, options?.shallow)
359356

360357
// mount the app!
361358
const vm = app.mount(el)

src/stubs.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export function stubComponents(
9292
// 1. a HTML tag (div, span...)
9393
// 2. An object of component options, such as { name: 'foo', render: [Function], props: {...} }
9494
// Depending what it is, we do different things.
95-
if (type === Transition || type === TransitionGroup) {
95+
if (type === Transition && stubs['transition']) {
96+
return [createTransitionStub({ props: undefined }), undefined, children]
97+
}
98+
99+
if (type === TransitionGroup && stubs['transition-group']) {
96100
return [createTransitionStub({ props: undefined }), undefined, children]
97101
}
98102

0 commit comments

Comments
 (0)