@@ -177,58 +177,57 @@ test("on(), multiple events at once and namespaces", function() {
177177test ( "on(), namespace with special add" , function ( ) {
178178 expect ( 27 ) ;
179179
180- var div = jQuery ( "<div/>" ) . on ( "test" , function ( e ) {
181- ok ( true , "Test event fired." ) ;
182- } ) ;
183-
184- var i = 0 ;
180+ var i = 0 ,
181+ div = jQuery ( "<div/>" ) . appendTo ( "#qunit-fixture" ) . on ( "test" , function ( e ) {
182+ ok ( true , "Test event fired." ) ;
183+ } ) ;
185184
186185 jQuery . event . special [ "test" ] = {
187- _default : function ( e , data ) {
188- equal ( this , document , "Make sure we're at the top of the chain ." ) ;
189- equal ( e . type , "test" , " And that we're still dealing with a test event ." ) ;
190- equal ( e . target , div [ 0 ] , "And that the target is correct." ) ;
191- ok ( data !== undefined , "And that trigger data was passed ." ) ;
186+ _default : function ( e , data ) {
187+ equal ( e . type , "test" , "Make sure we're dealing with a test event ." ) ;
188+ ok ( data , "And that trigger data was passed ." ) ;
189+ strictEqual ( e . target , div [ 0 ] , "And that the target is correct." ) ;
190+ equal ( this , window , "And that the context is correct ." ) ;
192191 } ,
193- setup : function ( ) { } ,
194- teardown : function ( ) {
195- ok ( true , "Teardown called." ) ;
192+ setup : function ( ) { } ,
193+ teardown : function ( ) {
194+ ok ( true , "Teardown called." ) ;
196195 } ,
197196 add : function ( handleObj ) {
198197 var handler = handleObj . handler ;
199- handleObj . handler = function ( e ) {
198+ handleObj . handler = function ( e ) {
200199 e . xyz = ++ i ;
201200 handler . apply ( this , arguments ) ;
202201 } ;
203202 } ,
204203 remove : function ( ) {
205- ok ( true , "Remove called." ) ;
204+ ok ( true , "Remove called." ) ;
206205 }
207206 } ;
208207
209- div . on ( "test.a" , { "x" : 1 } , function ( e ) {
208+ div . on ( "test.a" , { x : 1 } , function ( e ) {
210209 ok ( ! ! e . xyz , "Make sure that the data is getting passed through." ) ;
211210 equal ( e . data [ "x" ] , 1 , "Make sure data is attached properly." ) ;
212211 } ) ;
213212
214- div . on ( "test.b" , { "x" : 2 } , function ( e ) {
213+ div . on ( "test.b" , { x : 2 } , function ( e ) {
215214 ok ( ! ! e . xyz , "Make sure that the data is getting passed through." ) ;
216215 equal ( e . data [ "x" ] , 2 , "Make sure data is attached properly." ) ;
217216 } ) ;
218217
219218 // Should trigger 5
220- div . trigger ( "test" , 33.33 ) ;
219+ div . trigger ( "test" , 33.33 ) ;
221220
222221 // Should trigger 2
223- div . trigger ( "test.a" , "George Harrison" ) ;
222+ div . trigger ( "test.a" , "George Harrison" ) ;
224223
225224 // Should trigger 2
226- div . trigger ( "test.b" , { year : 1982 } ) ;
225+ div . trigger ( "test.b" , { year : 1982 } ) ;
227226
228227 // Should trigger 4
229228 div . off ( "test" ) ;
230229
231- div = jQuery ( "<div/>" ) . on ( "test" , function ( e ) {
230+ div = jQuery ( "<div/>" ) . on ( "test" , function ( e ) {
232231 ok ( true , "Test event fired." ) ;
233232 } ) ;
234233
0 commit comments