mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
fix(booleanAttrs): convert to boolean
jQuery's attr() does not handle 0 as false, when it comes to boolean attrs.
This commit is contained in:
@@ -23,6 +23,18 @@ describe('boolean attr directives', function() {
|
||||
}));
|
||||
|
||||
|
||||
it('should properly evaluate 0 as false', inject(function($rootScope, $compile) {
|
||||
// jQuery does not treat 0 as false, when setting attr()
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope)
|
||||
$rootScope.isDisabled = 0;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('disabled')).toBeFalsy();
|
||||
$rootScope.isDisabled = 1;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('disabled')).toBeTruthy();
|
||||
}));
|
||||
|
||||
|
||||
it('should bind disabled', inject(function($rootScope, $compile) {
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope)
|
||||
$rootScope.isDisabled = false;
|
||||
|
||||
Reference in New Issue
Block a user