@@ -30,28 +30,43 @@ test("default and pause with delegate", function(){
30
30
31
31
} ) ;
32
32
33
- test ( "default and pause with live" , function ( ) {
33
+ test ( "default and pause with live or on " , function ( ) {
34
34
$ ( "#qunit-test-area" ) . html ( "<div id='foo_default_pause'>hello</div>" )
35
35
36
- var order = [ ] ;
36
+ var order = [ ] ,
37
+ defaultShow = function ( ) {
38
+ order . push ( "default" )
39
+ } ,
40
+ show = function ( ev ) {
41
+ order . push ( 'show' )
42
+ ev . pause ( ) ;
43
+ setTimeout ( function ( ) {
44
+ ev . resume ( ) ;
45
+ setTimeout ( function ( ) {
46
+ start ( ) ;
47
+ same ( order , [ 'show' , 'default' ] ) ;
48
+ if ( $ . fn . live ) {
49
+ $ ( "#foo_default_pause" ) . die ( "show" ) ;
50
+ $ ( "#foo_default_pause" ) . die ( "default.show" ) ;
51
+ } else {
52
+ $ ( document . body ) . off ( "default.show" ) ;
53
+ $ ( document . body ) . off ( "show" ) ;
54
+ }
55
+
56
+ } , 30 )
57
+ } , 50 )
58
+ } ;
37
59
stop ( ) ;
38
60
39
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
40
- order . push ( "default" )
41
- } ) ;
42
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
43
- order . push ( 'show' )
44
- ev . pause ( ) ;
45
- setTimeout ( function ( ) {
46
- ev . resume ( ) ;
47
- setTimeout ( function ( ) {
48
- start ( ) ;
49
- same ( order , [ 'show' , 'default' ] )
50
- $ ( "#foo_default_pause" ) . die ( "show" ) ;
51
- $ ( "#foo_default_pause" ) . die ( "default.show" ) ;
52
- } , 30 )
53
- } , 50 )
54
- } ) ;
61
+ if ( $ . fn . live ) {
62
+ $ ( "#foo_default_pause" ) . live ( "default.show" , defaultShow ) ;
63
+ $ ( "#foo_default_pause" ) . live ( "show" , show ) ;
64
+ } else {
65
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , defaultShow ) ;
66
+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , show ) ;
67
+ }
68
+
69
+
55
70
56
71
57
72
$ ( "#foo_default_pause" ) . trigger ( "show" )
@@ -62,26 +77,37 @@ test("default and pause with live", function(){
62
77
test ( "triggerAsync" , function ( ) {
63
78
$ ( "#qunit-test-area" ) . html ( "<div id='foo_default_pause'>hello</div>" )
64
79
65
- var order = [ ] ;
66
- stop ( ) ;
67
-
68
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
69
- order . push ( "default" )
70
- } ) ;
71
-
72
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
73
- order . push ( 'show' )
74
- ev . pause ( ) ;
75
- setTimeout ( function ( ) {
76
- ev . resume ( ) ;
80
+ var order = [ ] ,
81
+ defaultShow = function ( ) {
82
+ order . push ( "default" )
83
+ } ,
84
+ show = function ( ev ) {
85
+ order . push ( 'show' )
86
+ ev . pause ( ) ;
77
87
setTimeout ( function ( ) {
78
- start ( ) ;
79
- $ ( "#foo_default_pause" ) . die ( )
80
- same ( order , [ 'show' , 'default' , 'async' ] )
81
- } , 30 )
82
- } , 50 )
83
- } ) ;
88
+ ev . resume ( ) ;
89
+ setTimeout ( function ( ) {
90
+ start ( ) ;
91
+ if ( $ . fn . die ) {
92
+ $ ( "#foo_default_pause" ) . die ( ) ;
93
+ } else {
94
+ $ ( document . body ) . off ( ) ;
95
+ }
96
+
97
+ same ( order , [ 'show' , 'default' , 'async' ] )
98
+ } , 30 )
99
+ } , 50 )
100
+ } ;
101
+
102
+ stop ( ) ;
84
103
104
+ if ( $ . fn . live ) {
105
+ $ ( "#foo_default_pause" ) . live ( "default.show" , defaultShow ) ;
106
+ $ ( "#foo_default_pause" ) . live ( "show" , show ) ;
107
+ } else {
108
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , defaultShow ) ;
109
+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , show ) ;
110
+ }
85
111
86
112
$ ( "#foo_default_pause" ) . triggerAsync ( "show" , function ( ) {
87
113
order . push ( "async" )
@@ -94,19 +120,20 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called be
94
120
var order = [ ] ;
95
121
stop ( ) ;
96
122
97
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
123
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause ", function ( ) {
98
124
order . push ( "default" )
99
125
} ) ;
100
126
101
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
127
+ $ ( document . body ) . on ( "show" , "#foo_default_pause ", function ( ev ) {
102
128
order . push ( 'show' ) ;
103
129
ev . preventDefault ( ) ;
104
130
ev . pause ( ) ;
105
131
setTimeout ( function ( ) {
106
132
ev . resume ( ) ;
107
133
setTimeout ( function ( ) {
108
134
start ( ) ;
109
- $ ( "#foo_default_pause" ) . die ( )
135
+ $ ( document . body ) . off ( "show" ) ;
136
+ $ ( document . body ) . off ( "default.show" )
110
137
same ( order , [ 'show' , 'prevented' ] )
111
138
} , 30 )
112
139
} , 50 )
@@ -125,11 +152,11 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
125
152
var order = [ ] ;
126
153
stop ( ) ;
127
154
128
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
155
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
129
156
order . push ( "default" )
130
157
} ) ;
131
158
132
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
159
+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , function ( ev ) {
133
160
order . push ( 'show' ) ;
134
161
135
162
ev . pause ( ) ;
@@ -138,7 +165,7 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
138
165
ev . resume ( ) ;
139
166
setTimeout ( function ( ) {
140
167
start ( ) ;
141
- $ ( "#foo_default_pause ") . die ( )
168
+ $ ( document . body ) . off ( "show ") . off ( "default.show" )
142
169
same ( order , [ 'show' , 'prevented' ] )
143
170
} , 30 )
144
171
} , 50 )
@@ -158,16 +185,16 @@ test("triggerAsync within another triggerAsync", function(){
158
185
var order = [ ] ;
159
186
stop ( ) ;
160
187
161
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
188
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
162
189
order . push ( "show default" )
163
190
} ) ;
164
- $ ( "#foo_default_pause" ) . live ( "default.hide" , function ( ) {
191
+ $ ( document . body ) . on ( "default.hide" , "#foo_default_pause ", function ( ) {
165
192
order . push ( "hide default" )
166
193
} ) ;
167
- $ ( "#foo_default_pause" ) . live ( "hide" , function ( ) {
194
+ $ ( document . body ) . on ( "hide" , "#foo_default_pause" , function ( ) {
168
195
order . push ( "hide" )
169
196
} ) ;
170
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
197
+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , function ( ev ) {
171
198
order . push ( 'show' ) ;
172
199
ev . pause ( ) ;
173
200
$ ( "#foo_default_pause" ) . triggerAsync ( "hide" , function ( ) {
@@ -176,7 +203,7 @@ test("triggerAsync within another triggerAsync", function(){
176
203
setTimeout ( function ( ) {
177
204
178
205
start ( ) ;
179
- $ ( "#foo_default_pause" ) . die ( )
206
+ $ ( document . body ) . off ( )
180
207
same ( order , [ 'show' , 'hide' , 'hide default' , "hide async" , "show default" , "show async" ] )
181
208
} , 30 )
182
209
@@ -199,16 +226,16 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
199
226
var order = [ ] ;
200
227
stop ( ) ;
201
228
202
- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
229
+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
203
230
order . push ( "show default" )
204
231
} ) ;
205
- $ ( "#foo_default_pause" ) . live ( "default.hide" , function ( ) {
232
+ $ ( document . body ) . on ( "default.hide" , "#foo_default_pause ", function ( ) {
206
233
order . push ( "hide default" )
207
234
} ) ;
208
- $ ( "#foo_default_pause" ) . live ( "hide" , function ( ) {
235
+ $ ( document . body ) . on ( "hide" , "#foo_default_pause" , function ( ) {
209
236
order . push ( "hide" )
210
237
} ) ;
211
- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
238
+ $ ( document . body ) . on ( "show" , "#foo_default_pause ", function ( ev ) {
212
239
order . push ( 'show' ) ;
213
240
ev . preventDefault ( ) ;
214
241
ev . pause ( ) ;
@@ -217,7 +244,7 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
217
244
ev . resume ( ) ;
218
245
setTimeout ( function ( ) {
219
246
start ( ) ;
220
- $ ( "#foo_default_pause" ) . die ( )
247
+ $ ( document . body ) . off ( )
221
248
same ( order , [ 'show' , 'hide' , 'hide default' , "hide async" , "show prevented" ] )
222
249
} , 30 )
223
250
0 commit comments