From 27e9340b3c25b512e45213b39811098d07e12e3b Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 7 Nov 2013 16:19:03 -0800 Subject: 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. --- test/jqLiteSpec.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/jqLiteSpec.js') 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('foo'); + 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('foo'); + 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(''); + 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('
'); + 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('
'), -- cgit v1.2.3