mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-13 08:56:40 +08:00
BREAKING CHANGE: The `blur` and `focus` event fire synchronously, also during DOM operations that remove elements. This lead to errors as the Angular model was not in a consistent state. See this [fiddle](http://jsfiddle.net/fq1dq5yb/) for a demo. This change executes the expression of those events using `scope.$evalAsync` if an `$apply` is in progress, otherwise keeps the old behavior. Fixes #4979 Fixes #5945 Closes #8803 Closes #6910 Closes #5402
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
describe('ngKeyup and ngKeydown directives', function() {
|
|
var element;
|
|
|
|
afterEach(function() {
|
|
dealoc(element);
|
|
});
|
|
|
|
it('should get called on a keyup', inject(function($rootScope, $compile) {
|
|
element = $compile('<input ng-keyup="touched = true">')($rootScope);
|
|
$rootScope.$digest();
|
|
expect($rootScope.touched).toBeFalsy();
|
|
|
|
browserTrigger(element, 'keyup');
|
|
expect($rootScope.touched).toEqual(true);
|
|
}));
|
|
|
|
it('should get called on a keydown', inject(function($rootScope, $compile) {
|
|
element = $compile('<input ng-keydown="touched = true">')($rootScope);
|
|
$rootScope.$digest();
|
|
expect($rootScope.touched).toBeFalsy();
|
|
|
|
browserTrigger(element, 'keydown');
|
|
expect($rootScope.touched).toEqual(true);
|
|
}));
|
|
|
|
it('should get called on a keypress', inject(function($rootScope, $compile) {
|
|
element = $compile('<input ng-keypress="touched = true">')($rootScope);
|
|
$rootScope.$digest();
|
|
expect($rootScope.touched).toBeFalsy();
|
|
|
|
browserTrigger(element, 'keypress');
|
|
expect($rootScope.touched).toEqual(true);
|
|
}));
|
|
|
|
});
|
|
|