-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Fix/jquery touch #10797
Fix/jquery touch #10797
Changes from all commits
9df0531
02d9274
286593a
9c59d7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,27 @@ describe('ngClick (touch)', function() { | |
})); | ||
|
||
|
||
it('should unwrap a jQuery-wrapped event object on touchstart/touchend', inject(function($rootScope, $compile) { | ||
element = $compile('<div ng-click="event = $event"></div>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
browserTrigger(element, 'touchstart'); | ||
browserTrigger(element, 'touchend'); | ||
expect($rootScope.event.originalEvent).toBeUndefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather you check here for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, this test will pass even if only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This would be a false positive on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgalfaso We should most likely just create a Protractor test for such stuff, too much hacking must happen here to test anything. |
||
expect($rootScope.event.clientX).toBeDefined(); | ||
expect($rootScope.event.clientY).toBeDefined(); | ||
})); | ||
|
||
|
||
it('should unwrap a jQuery-wrapped event object on click', inject(function($rootScope, $compile) { | ||
element = $compile('<div ng-click="event = $event"></div>')($rootScope); | ||
$rootScope.$digest(); | ||
|
||
browserTrigger(element, 'click'); | ||
expect($rootScope.event.originalEvent).toBeUndefined(); | ||
})); | ||
|
||
|
||
it('should not click if the touch is held too long', inject(function($rootScope, $compile, $rootElement) { | ||
element = $compile('<div ng-click="count = count + 1"></div>')($rootScope); | ||
$rootElement.append(element); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion: as far as I know, there's no "originalEvent" in
touches[0]
- only in the event itself. This would allow you to reduce these two variables to:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - thanks for noticing it. I guess I'd just like to get it merged sooner rather than later, and then we can clean it up. Let's see what @mzgol says.