diff options
| author | Misko Hevery | 2012-06-04 15:06:02 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-06-08 15:27:03 -0700 | 
| commit | 9be82d942fc6ab2772197c84a35a4c374c604cbc (patch) | |
| tree | 9d59b22537cd5eefbd5419ca6eeda363b437f42c /test/ng/compileSpec.js | |
| parent | 2491319575f26fa8247b247247e223d5822ee61c (diff) | |
| download | angular.js-9be82d942fc6ab2772197c84a35a4c374c604cbc.tar.bz2 | |
refactor($compile): always call attr.$observe
attr.$observe used to call function only if there was interpolation
on that attribute. We now call the observation function all the time
but we only save the reference to it if interpolation is present.
Diffstat (limited to 'test/ng/compileSpec.js')
| -rw-r--r-- | test/ng/compileSpec.js | 22 | 
1 files changed, 12 insertions, 10 deletions
| diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index a6a81a0e..655d48cc 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1249,15 +1249,15 @@ describe('$compile', function() {    describe('interpolation', function() { -    var observeSpy, attrValueDuringLinking; +    var observeSpy, directiveAttrs;      beforeEach(module(function() {        directive('observer', function() {          return function(scope, elm, attr) { +          directiveAttrs = attr;            observeSpy = jasmine.createSpy('$observe attr');            expect(attr.$observe('someAttr', observeSpy)).toBe(observeSpy); -          attrValueDuringLinking = attr.someAttr;          };        });      })); @@ -1295,19 +1295,21 @@ describe('$compile', function() {      it('should set interpolated attrs to undefined', inject(function($rootScope, $compile) { -      attrValueDuringLinking = null;        $compile('<div some-attr="{{whatever}}" observer></div>')($rootScope); -      expect(attrValueDuringLinking).toBeUndefined(); +      expect(directiveAttrs.someAttr).toBeUndefined();      })); -    it('should not call observer of non-interpolated attr', inject(function($rootScope, $compile) { -      $compile('<div some-attr="nonBound" observer></div>')($rootScope); -      expect(attrValueDuringLinking).toBe('nonBound'); +    it('should call observer of non-interpolated attr through $evalAsync', +      inject(function($rootScope, $compile) { +        $compile('<div some-attr="nonBound" observer></div>')($rootScope); +        expect(directiveAttrs.someAttr).toBe('nonBound'); -      $rootScope.$digest(); -      expect(observeSpy).not.toHaveBeenCalled(); -    })); +        expect(observeSpy).not.toHaveBeenCalled(); +        $rootScope.$digest(); +        expect(observeSpy).toHaveBeenCalled(); +      }) +    );      it('should delegate exceptions to $exceptionHandler', function() { | 
