diff options
| author | Igor Minar | 2013-11-07 16:19:03 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-11-07 22:08:22 -0800 | 
| commit | 27e9340b3c25b512e45213b39811098d07e12e3b (patch) | |
| tree | 63f817a20eea62f813fcf85ad40c1b8bcc6e1652 /test/jqLiteSpec.js | |
| parent | b5af198f0d5b0f2b3ddb31ea12f700f3e0616271 (diff) | |
| download | angular.js-27e9340b3c25b512e45213b39811098d07e12e3b.tar.bz2 | |
feat(jqLite): expose isolateScope() getter similar to scope()
See doc update in the diff for more info.
BREAKING CHANGE: jqLite#scope() does not return the isolate scope on the element
that triggered directive with isolate scope. Use jqLite#isolateScope() instead.
Diffstat (limited to 'test/jqLiteSpec.js')
| -rw-r--r-- | test/jqLiteSpec.js | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 24920273..02a17df8 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -151,6 +151,13 @@ describe('jqLite', function() {        dealoc(element);      }); +    it('should retrieve isolate scope attached to the current element', function() { +      var element = jqLite('<i>foo</i>'); +      element.data('$isolateScope', scope); +      expect(element.isolateScope()).toBe(scope); +      dealoc(element); +    }); +      it('should retrieve scope attached to the html element if its requested on the document',          function() {        var doc = jqLite(document), @@ -182,6 +189,33 @@ describe('jqLite', function() {    }); +  describe('isolateScope', function() { + +    it('should retrieve isolate scope attached to the current element', function() { +      var element = jqLite('<i>foo</i>'); +      element.data('$isolateScope', scope); +      expect(element.isolateScope()).toBe(scope); +      dealoc(element); +    }); + + +    it('should not walk up the dom to find scope', function() { +      var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>'); +      var deepChild = jqLite(element[0].getElementsByTagName('b')[0]); +      element.data('$isolateScope', scope); +      expect(deepChild.isolateScope()).toBeUndefined(); +      dealoc(element); +    }); + + +    it('should return undefined when no scope was found', function() { +      var element = jqLite('<div></div>'); +      expect(element.isolateScope()).toBeFalsy(); +      dealoc(element); +    }); +  }); + +    describe('injector', function() {      it('should retrieve injector attached to the current element or its parent', function() {        var template = jqLite('<div><span></span></div>'), | 
