aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIgor Minar2011-01-23 15:55:11 -0800
committerIgor Minar2011-01-24 14:03:42 -0800
commit5340d1e0b1c29103e187a1cdc33bbee48d98a74d (patch)
tree81371510596d7ac7aa4300f16fa58c92527f298a /test
parent8d91ec4173a652da9fe984d12a50d6b1b4ef935f (diff)
downloadangular.js-5340d1e0b1c29103e187a1cdc33bbee48d98a74d.tar.bz2
fix for infinite loop in retrieveScope with jQuery + specs
- retrieveScope run into infinite loop if called on DOM tree that doesn't contain scope reference (happens only with jQuery) - added missing specs for retrieveScope function
Diffstat (limited to 'test')
-rw-r--r--test/CompilerSpec.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js
index d8c7c1b8..76d3d1ca 100644
--- a/test/CompilerSpec.js
+++ b/test/CompilerSpec.js
@@ -167,4 +167,23 @@ describe('compiler', function(){
expect(sortedHtml(scope.$element)).toEqual('<div>A<hr></hr>B<hr></hr>C<p></p>D</div>');
});
+
+ describe('retrieveScope', function() {
+ it('should retrieve scope attached to the current element', function() {
+ scope = compile('<i>foo</i>');
+ expect(retrieveScope(scope.$element)).toBe(scope);
+ });
+
+ it('should walk up the dom to find scope', function() {
+ scope = compile('<ul><li><p><b>deep deep</b><p></li></ul>');
+ var deepChild = scope.$element[0].getElementsByTagName('b')[0];
+ expect(retrieveScope(deepChild)).toBe(scope);
+ });
+
+ it('should return undefined when no scope was found', function() {
+ var html = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>'),
+ deepChild = html[0].getElementsByTagName('b')[0];
+ expect(retrieveScope(deepChild)).toBeNull();
+ });
+ });
});