Skip to content

Commit 10e724f

Browse files
committed
support string values for transition duration
1 parent 72a8c13 commit 10e724f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/platforms/web/runtime/components/transition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const transitionProps = {
2222
appearClass: String,
2323
appearActiveClass: String,
2424
appearToClass: String,
25-
duration: [Number, Object]
25+
duration: [Number, String, Object]
2626
}
2727

2828
// in case the child is also an abstract component, e.g. <keep-alive>

src/platforms/web/runtime/modules/transition.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { once, isObject } from 'shared/util'
3+
import { once, isObject, toNumber } from 'shared/util'
44
import { inBrowser, isIE9, warn } from 'core/util/index'
55
import { mergeVNodeHook } from 'core/vdom/helpers/index'
66
import { activeInstance } from 'core/instance/lifecycle'
@@ -77,7 +77,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
7777
const afterEnterHook = isAppear ? (afterAppear || afterEnter) : afterEnter
7878
const enterCancelledHook = isAppear ? (appearCancelled || enterCancelled) : enterCancelled
7979

80-
const explicitEnterDuration = isObject(duration) ? duration.enter : duration
80+
const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration)
8181
if (process.env.NODE_ENV !== 'production' && explicitEnterDuration != null) {
8282
checkDuration(explicitEnterDuration, 'enter', vnode)
8383
}
@@ -179,7 +179,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
179179
const expectsCSS = css !== false && !isIE9
180180
const userWantsControl = getHookAgumentsLength(leave)
181181

182-
const explicitLeaveDuration = isObject(duration) ? duration.leave : duration
182+
const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration)
183183
if (process.env.NODE_ENV !== 'production' && explicitLeaveDuration != null) {
184184
checkDuration(explicitLeaveDuration, 'leave', vnode)
185185
}

test/unit/features/transition/transition.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ if (!isIE9) {
882882
const vm = new Vue({
883883
template: `
884884
<div>
885-
<transition :duration="${explicitDuration}">
885+
<transition duration="${explicitDuration}">
886886
<div v-if="ok" class="test">foo</div>
887887
</transition>
888888
</div>

0 commit comments

Comments
 (0)