File tree 3 files changed +46
-5
lines changed
3 files changed +46
-5
lines changed Original file line number Diff line number Diff line change 168
168
function untrackDocument ( stateObj ) {
169
169
document . removeEventListener ( 'mousemove' , stateObj . movefn ) ;
170
170
document . removeEventListener ( 'mouseup' , stateObj . upfn ) ;
171
+ stateObj . movefn = null ;
172
+ stateObj . upfn = null ;
171
173
}
172
174
173
175
var Gestures = {
416
418
emits : [ 'down' , 'up' ] ,
417
419
418
420
info : {
419
- movefn : function ( ) { } ,
420
- upfn : function ( ) { }
421
+ movefn : null ,
422
+ upfn : null
421
423
} ,
422
424
423
425
reset : function ( ) {
486
488
}
487
489
this . moves . push ( move ) ;
488
490
} ,
489
- movefn : function ( ) { } ,
490
- upfn : function ( ) { } ,
491
+ movefn : null ,
492
+ upfn : null ,
491
493
prevent : false
492
494
} ,
493
495
Original file line number Diff line number Diff line change 148
148
stream : {
149
149
type : Array ,
150
150
value : function ( ) {
151
- return [ ] ;
151
+ return [ ] ;
152
152
}
153
153
}
154
154
} ,
Original file line number Diff line number Diff line change 406
406
assert . equal ( el . stream . length , 1 ) ;
407
407
} ) ;
408
408
} ) ;
409
+
410
+ suite ( 'Reference Cleanup' , function ( ) {
411
+ var el ;
412
+
413
+ setup ( function ( ) {
414
+ el = document . createElement ( 'x-buttons' ) ;
415
+ document . body . appendChild ( el ) ;
416
+ } ) ;
417
+
418
+ teardown ( function ( ) {
419
+ document . body . removeChild ( el ) ;
420
+ } ) ;
421
+
422
+ test ( 'down and up clear document tracking' , function ( ) {
423
+ var ev = new CustomEvent ( 'mousedown' , { bubbles : true } ) ;
424
+ el . dispatchEvent ( ev ) ;
425
+
426
+ // some recognizers do not track the document, like tap
427
+ var recognizers = Polymer . Gestures . recognizers . filter ( function ( r ) {
428
+ return r . info . hasOwnProperty ( 'movefn' ) &&
429
+ r . info . hasOwnProperty ( 'upfn' ) ;
430
+ } ) ;
431
+
432
+ assert . isAbove ( recognizers . length , 0 , 'some recognizers track the document' ) ;
433
+
434
+ recognizers . forEach ( function ( r ) {
435
+ assert . isFunction ( r . info . movefn , r . name + ' movefn' ) ;
436
+ assert . isFunction ( r . info . upfn , r . name + ' upfn' ) ;
437
+ } ) ;
438
+
439
+ ev = new CustomEvent ( 'mouseup' , { bubbles : true } ) ;
440
+ el . dispatchEvent ( ev ) ;
441
+
442
+ recognizers . forEach ( function ( r ) {
443
+ assert . isNull ( r . info . movefn , r . name + ' movefn' ) ;
444
+ assert . isNull ( r . info . upfn , r . name + ' upfn' ) ;
445
+ } ) ;
446
+ } ) ;
447
+ } ) ;
409
448
</ script >
410
449
411
450
</ body >
You can’t perform that action at this time.
0 commit comments