aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/ngViewSpec.js
diff options
context:
space:
mode:
authorPete Bacon Darwin2013-02-18 12:05:16 +0000
committerPete Bacon Darwin2013-02-18 13:04:24 +0000
commit1f23cfe9c751f84d9fc996df6d54961b2e46e868 (patch)
tree5561063efeeded3a90014dcc870df5d06d441087 /test/ng/directive/ngViewSpec.js
parent0fa8e47fb5d2df5aab820691696f19662669eed0 (diff)
downloadangular.js-1f23cfe9c751f84d9fc996df6d54961b2e46e868.tar.bz2
fix(compile): should not leak memory when there are top level empty text nodes
The change to prevent <span> elements being wrapped around empty text nodes caused these empty text nodes to have scopes and controllers attached, through jqLite.data() calls, which led to memory leaks and errors in IE8. Now we exclude all but document nodes and elements from having jqLite.data() set both in the compiler and in ng-view. Fixes: #1968 and #1876
Diffstat (limited to 'test/ng/directive/ngViewSpec.js')
-rw-r--r--test/ng/directive/ngViewSpec.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/ng/directive/ngViewSpec.js b/test/ng/directive/ngViewSpec.js
index e90bb3bd..e781b98b 100644
--- a/test/ng/directive/ngViewSpec.js
+++ b/test/ng/directive/ngViewSpec.js
@@ -429,7 +429,7 @@ describe('ngView', function() {
$rootScope.$digest();
expect($rootScope.load).toHaveBeenCalledOnce();
});
- })
+ });
it('should set $scope and $controllerController on the view', function() {
@@ -459,4 +459,28 @@ describe('ngView', function() {
expect(div.controller()).toBe($route.current.scope.ctrl);
});
});
+
+ it('should not set $scope or $controllerController on top level text elements in the view', function() {
+ function MyCtrl($scope) {}
+
+ module(function($routeProvider) {
+ $routeProvider.when('/foo', {templateUrl: 'tpl.html', controller: MyCtrl});
+ });
+
+ inject(function($templateCache, $location, $rootScope, $route) {
+ $templateCache.put('tpl.html', '<div></div> ');
+ $location.url('/foo');
+ $rootScope.$digest();
+
+ forEach(element.contents(), function(node) {
+ if ( node.nodeType == 3 ) {
+ expect(jqLite(node).scope()).not.toBe($route.current.scope);
+ expect(jqLite(node).controller()).not.toBeDefined();
+ } else {
+ expect(jqLite(node).scope()).toBe($route.current.scope);
+ expect(jqLite(node).controller()).toBeDefined();
+ }
+ });
+ });
+ });
});