diff options
| author | Vojta Jina | 2012-04-04 08:12:39 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2012-04-04 08:26:28 -0700 | 
| commit | dcb8e0767fbf0a7a55f3b0045fd01b2532ea5441 (patch) | |
| tree | 3726eac589962daf7036889cc5722310096d949d /test | |
| parent | 21b77ad5c231ab0e05eb89f22005f7ed8d40a6c1 (diff) | |
| download | angular.js-dcb8e0767fbf0a7a55f3b0045fd01b2532ea5441.tar.bz2 | |
fix(booleanAttrs): convert to boolean
jQuery's attr() does not handle 0 as false, when it comes to boolean attrs.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/directive/booleanAttrDirSpecs.js | 12 | 
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ng/directive/booleanAttrDirSpecs.js b/test/ng/directive/booleanAttrDirSpecs.js index aa84c1ae..d58ffced 100644 --- a/test/ng/directive/booleanAttrDirSpecs.js +++ b/test/ng/directive/booleanAttrDirSpecs.js @@ -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;  | 
