File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 111
111
}
112
112
}
113
113
114
+ function isSyntheticClick ( ev ) {
115
+ if ( ev . type === 'click' ) {
116
+ // ev.detail is 0 for HTMLElement.click in most browsers
117
+ if ( ev . detail === 0 ) {
118
+ return true ;
119
+ }
120
+ // in the worst case, check that the x/y position of the click is within
121
+ // the bounding box of the target of the event
122
+ // Thanks IE 10 >:(
123
+ var t = Gestures . findOriginalTarget ( ev ) ;
124
+ var bcr = t . getBoundingClientRect ( ) ;
125
+ // use page x/y to account for scrolling
126
+ var x = ev . pageX , y = ev . pageY ;
127
+ return ( x >= bcr . left && x <= bcr . right ) &&
128
+ ( y >= bcr . top && y <= bcr . bottom ) ;
129
+ }
130
+ return false ;
131
+ }
132
+
114
133
var POINTERSTATE = {
115
134
mouse : {
116
135
target : null ,
624
643
var dy = Math . abs ( e . clientY - this . info . y ) ;
625
644
var t = Gestures . findOriginalTarget ( e ) ;
626
645
// dx,dy can be NaN if `click` has been simulated and there was no `down` for `start`
627
- if ( isNaN ( dx ) || isNaN ( dy ) || ( dx <= TAP_DISTANCE && dy <= TAP_DISTANCE ) ) {
646
+ if ( isNaN ( dx ) || isNaN ( dy ) || ( dx <= TAP_DISTANCE && dy <= TAP_DISTANCE ) || isSyntheticClick ( e ) ) {
628
647
// prevent taps from being generated if an event has canceled them
629
648
if ( ! this . info . prevent ) {
630
649
Gestures . fire ( t , 'tap' , {
Original file line number Diff line number Diff line change 53
53
assert . equal ( foo . _testRootTarget , div , 'foo root target' ) ;
54
54
} ) ;
55
55
56
+ test ( 'HTMLElement.click triggers tap' , function ( ) {
57
+ // make a mousedown *very* far away to tickle the distance check
58
+ var ev = new CustomEvent ( 'mousedown' ) ;
59
+ ev . clientX = 1e8 ;
60
+ ev . clientY = 1e8 ;
61
+ app . dispatchEvent ( ev ) ;
62
+ app . click ( ) ;
63
+ assert . equal ( app . _testLocalTarget , app , 'app local target' ) ;
64
+ assert . equal ( app . _testRootTarget , app , 'app root target' ) ;
65
+ } ) ;
56
66
} ) ;
57
67
58
68
suite ( 'Event Setup and Teardown' , function ( ) {
You can’t perform that action at this time.
0 commit comments