@@ -30,28 +30,43 @@ test("default and pause with delegate", function(){
3030
3131} ) ;
3232
33- test ( "default and pause with live" , function ( ) {
33+ test ( "default and pause with live or on " , function ( ) {
3434 $ ( "#qunit-test-area" ) . html ( "<div id='foo_default_pause'>hello</div>" )
3535
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+ } ;
3759 stop ( ) ;
3860
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+
5570
5671
5772 $ ( "#foo_default_pause" ) . trigger ( "show" )
@@ -62,26 +77,37 @@ test("default and pause with live", function(){
6277test ( "triggerAsync" , function ( ) {
6378 $ ( "#qunit-test-area" ) . html ( "<div id='foo_default_pause'>hello</div>" )
6479
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 ( ) ;
7787 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 ( ) ;
84103
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+ }
85111
86112 $ ( "#foo_default_pause" ) . triggerAsync ( "show" , function ( ) {
87113 order . push ( "async" )
@@ -94,19 +120,20 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called be
94120 var order = [ ] ;
95121 stop ( ) ;
96122
97- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
123+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause ", function ( ) {
98124 order . push ( "default" )
99125 } ) ;
100126
101- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
127+ $ ( document . body ) . on ( "show" , "#foo_default_pause ", function ( ev ) {
102128 order . push ( 'show' ) ;
103129 ev . preventDefault ( ) ;
104130 ev . pause ( ) ;
105131 setTimeout ( function ( ) {
106132 ev . resume ( ) ;
107133 setTimeout ( function ( ) {
108134 start ( ) ;
109- $ ( "#foo_default_pause" ) . die ( )
135+ $ ( document . body ) . off ( "show" ) ;
136+ $ ( document . body ) . off ( "default.show" )
110137 same ( order , [ 'show' , 'prevented' ] )
111138 } , 30 )
112139 } , 50 )
@@ -125,11 +152,11 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
125152 var order = [ ] ;
126153 stop ( ) ;
127154
128- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
155+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
129156 order . push ( "default" )
130157 } ) ;
131158
132- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
159+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , function ( ev ) {
133160 order . push ( 'show' ) ;
134161
135162 ev . pause ( ) ;
@@ -138,7 +165,7 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
138165 ev . resume ( ) ;
139166 setTimeout ( function ( ) {
140167 start ( ) ;
141- $ ( "#foo_default_pause ") . die ( )
168+ $ ( document . body ) . off ( "show ") . off ( "default.show" )
142169 same ( order , [ 'show' , 'prevented' ] )
143170 } , 30 )
144171 } , 50 )
@@ -158,16 +185,16 @@ test("triggerAsync within another triggerAsync", function(){
158185 var order = [ ] ;
159186 stop ( ) ;
160187
161- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
188+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
162189 order . push ( "show default" )
163190 } ) ;
164- $ ( "#foo_default_pause" ) . live ( "default.hide" , function ( ) {
191+ $ ( document . body ) . on ( "default.hide" , "#foo_default_pause ", function ( ) {
165192 order . push ( "hide default" )
166193 } ) ;
167- $ ( "#foo_default_pause" ) . live ( "hide" , function ( ) {
194+ $ ( document . body ) . on ( "hide" , "#foo_default_pause" , function ( ) {
168195 order . push ( "hide" )
169196 } ) ;
170- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
197+ $ ( document . body ) . on ( "show" , "#foo_default_pause" , function ( ev ) {
171198 order . push ( 'show' ) ;
172199 ev . pause ( ) ;
173200 $ ( "#foo_default_pause" ) . triggerAsync ( "hide" , function ( ) {
@@ -176,7 +203,7 @@ test("triggerAsync within another triggerAsync", function(){
176203 setTimeout ( function ( ) {
177204
178205 start ( ) ;
179- $ ( "#foo_default_pause" ) . die ( )
206+ $ ( document . body ) . off ( )
180207 same ( order , [ 'show' , 'hide' , 'hide default' , "hide async" , "show default" , "show async" ] )
181208 } , 30 )
182209
@@ -199,16 +226,16 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
199226 var order = [ ] ;
200227 stop ( ) ;
201228
202- $ ( "#foo_default_pause" ) . live ( "default.show" , function ( ) {
229+ $ ( document . body ) . on ( "default.show" , "#foo_default_pause" , function ( ) {
203230 order . push ( "show default" )
204231 } ) ;
205- $ ( "#foo_default_pause" ) . live ( "default.hide" , function ( ) {
232+ $ ( document . body ) . on ( "default.hide" , "#foo_default_pause ", function ( ) {
206233 order . push ( "hide default" )
207234 } ) ;
208- $ ( "#foo_default_pause" ) . live ( "hide" , function ( ) {
235+ $ ( document . body ) . on ( "hide" , "#foo_default_pause" , function ( ) {
209236 order . push ( "hide" )
210237 } ) ;
211- $ ( "#foo_default_pause" ) . live ( "show" , function ( ev ) {
238+ $ ( document . body ) . on ( "show" , "#foo_default_pause ", function ( ev ) {
212239 order . push ( 'show' ) ;
213240 ev . preventDefault ( ) ;
214241 ev . pause ( ) ;
@@ -217,7 +244,7 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
217244 ev . resume ( ) ;
218245 setTimeout ( function ( ) {
219246 start ( ) ;
220- $ ( "#foo_default_pause" ) . die ( )
247+ $ ( document . body ) . off ( )
221248 same ( order , [ 'show' , 'hide' , 'hide default' , "hide async" , "show prevented" ] )
222249 } , 30 )
223250
0 commit comments