Skip to content

Commit 8a37764

Browse files
committed
resolve js transition effect during compilation rather than at transition
1 parent ab254f7 commit 8a37764

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

src/directives/transition.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ module.exports = {
55

66
bind: function () {
77
this.el.__v_trans = {
8-
id: this.expression
8+
id: this.expression,
9+
// resolve the custom transition functions now
10+
fns: this.vm.$options.transitions[this.expression]
911
}
1012
}
1113

src/transition/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ var apply = exports.apply = function (el, direction, op, vm, cb) {
122122
return
123123
}
124124
// determine the transition type on the element
125-
var jsTransition = vm.$options.transitions[transData.id]
125+
var jsTransition = transData.fns
126126
if (jsTransition) {
127127
// js
128128
applyJSTransition(

test/unit/specs/directives/transition_spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@ var def = require('../../../../src/directives/transition')
44
if (_.inBrowser) {
55
describe('v-transition', function () {
66

7-
it('should save the transition id as data', function () {
7+
it('should save the transition id and custom functions as data', function () {
8+
var fns = {}
89
var dir = {
910
el: document.createElement('div'),
1011
expression: 'test',
11-
bind: def.bind
12+
bind: def.bind,
13+
vm: {
14+
$options: {
15+
transitions: {
16+
test: fns
17+
}
18+
}
19+
}
1220
}
1321
dir.bind()
1422
expect(dir.el.__v_trans.id).toBe('test')
23+
expect(dir.el.__v_trans.fns).toBe(fns)
1524
})
1625

1726
})

test/unit/specs/transition/transition_spec.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,13 @@ if (_.inBrowser && !_.isIE9) {
305305
var el, vm, op, cb, def, emitter
306306
beforeEach(function () {
307307
emitter = {}
308+
def = {}
308309
el = document.createElement('div')
309-
el.__v_trans = { id: 'test' }
310+
el.__v_trans = { id: 'test', fns: def }
310311
document.body.appendChild(el)
311312
op = jasmine.createSpy('js transition op')
312313
cb = jasmine.createSpy('js transition cb')
313-
def = {}
314-
vm = new Vue({
315-
el: el,
316-
transitions: {
317-
test: def
318-
}
319-
})
314+
vm = new Vue({ el: el })
320315
})
321316

322317
afterEach(function () {

0 commit comments

Comments
 (0)