@@ -121,7 +121,7 @@ if (!_.isIE9) {
121
121
122
122
describe ( 'CSS transitions' , function ( ) {
123
123
var vm , el , op , cb , hooks
124
- beforeEach ( function ( done ) {
124
+ beforeEach ( function ( ) {
125
125
el = document . createElement ( 'div' )
126
126
el . textContent = 'hello'
127
127
vm = new Vue ( { el : el } )
@@ -138,7 +138,9 @@ if (!_.isIE9) {
138
138
}
139
139
// !IMPORTANT!
140
140
// this ensures we force a layout for every test.
141
- _ . nextTick ( done )
141
+ /* eslint-disable no-unused-vars */
142
+ var f = document . body . offsetHeight
143
+ /* eslint-enable no-unused-vars */
142
144
} )
143
145
144
146
afterEach ( function ( ) {
@@ -221,12 +223,42 @@ if (!_.isIE9) {
221
223
} )
222
224
} )
223
225
226
+ it ( 'transition enter for svg' , function ( done ) {
227
+ el . innerHTML = '<svg><circle cx="0" cy="0" r="10"></circle></svg>'
228
+ var svg = el . querySelector ( 'svg' )
229
+ var circle = el . querySelector ( 'circle' )
230
+ svg . removeChild ( circle )
231
+ circle . __v_trans = new Transition ( circle , 'test' , hooks , vm )
232
+ // inline style
233
+ circle . style . transition =
234
+ circle . style . WebkitTransition = 'opacity ' + duration + ' ease'
235
+ transition . applyTransition ( circle , 1 , function ( ) {
236
+ svg . appendChild ( circle )
237
+ op ( )
238
+ } , vm , cb )
239
+ expect ( hooks . beforeEnter ) . toHaveBeenCalled ( )
240
+ expect ( hooks . enter ) . toHaveBeenCalled ( )
241
+ expect ( op ) . toHaveBeenCalled ( )
242
+ expect ( cb ) . not . toHaveBeenCalled ( )
243
+ _ . nextTick ( function ( ) {
244
+ expect ( circle . getAttribute ( 'class' ) . indexOf ( 'test-enter' ) > - 1 ) . toBe ( false )
245
+ expect ( hooks . afterEnter ) . not . toHaveBeenCalled ( )
246
+ _ . on ( circle , _ . transitionEndEvent , function ( ) {
247
+ expect ( cb ) . toHaveBeenCalled ( )
248
+ expect ( hooks . afterEnter ) . toHaveBeenCalled ( )
249
+ done ( )
250
+ } )
251
+ } )
252
+ } )
253
+
224
254
it ( 'transition leave' , function ( done ) {
225
255
el . __v_trans = new Transition ( el , 'test' , hooks , vm )
226
256
// cascaded class style
227
257
el . classList . add ( 'test' )
228
258
// force a layout here so the transition can be triggered
259
+ /* eslint-disable no-unused-vars */
229
260
var f = el . offsetHeight
261
+ /* eslint-enable no-unused-vars */
230
262
transition . applyTransition ( el , - 1 , op , vm , cb )
231
263
expect ( hooks . beforeLeave ) . toHaveBeenCalled ( )
232
264
expect ( hooks . leave ) . toHaveBeenCalled ( )
@@ -243,7 +275,32 @@ if (!_.isIE9) {
243
275
done ( )
244
276
} )
245
277
} )
246
- return f
278
+ } )
279
+
280
+ it ( 'transition leave for svg' , function ( done ) {
281
+ el . innerHTML = '<svg><circle cx="0" cy="0" r="10" class="test"></circle></svg>'
282
+ var circle = el . querySelector ( 'circle' )
283
+ circle . __v_trans = new Transition ( circle , 'test' , hooks , vm )
284
+ // force a layout here so the transition can be triggered
285
+ /* eslint-disable no-unused-vars */
286
+ var f = el . offsetHeight
287
+ /* eslint-enable no-unused-vars */
288
+ transition . applyTransition ( circle , - 1 , op , vm , cb )
289
+ expect ( hooks . beforeLeave ) . toHaveBeenCalled ( )
290
+ expect ( hooks . leave ) . toHaveBeenCalled ( )
291
+ _ . nextTick ( function ( ) {
292
+ expect ( op ) . not . toHaveBeenCalled ( )
293
+ expect ( cb ) . not . toHaveBeenCalled ( )
294
+ expect ( hooks . afterLeave ) . not . toHaveBeenCalled ( )
295
+ expect ( circle . getAttribute ( 'class' ) . indexOf ( 'test-leave' ) > - 1 ) . toBe ( true )
296
+ _ . on ( circle , _ . transitionEndEvent , function ( ) {
297
+ expect ( op ) . toHaveBeenCalled ( )
298
+ expect ( cb ) . toHaveBeenCalled ( )
299
+ expect ( circle . getAttribute ( 'class' ) . indexOf ( 'test-leave' ) > - 1 ) . toBe ( false )
300
+ expect ( hooks . afterLeave ) . toHaveBeenCalled ( )
301
+ done ( )
302
+ } )
303
+ } )
247
304
} )
248
305
249
306
it ( 'animation enter' , function ( done ) {
0 commit comments