aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngMock/angular-mocks.js
diff options
context:
space:
mode:
authorMisko Hevery2012-05-09 19:27:15 -0400
committerIgor Minar2012-05-14 21:56:22 -0700
commitec1c5dfaee32f9638cedd28bb96bbbecce9d0cf0 (patch)
tree13272649b7df2eb8e9f0d629df527983d66c5d57 /src/ngMock/angular-mocks.js
parent24e7da4f1954dbe2e89f82950ed00292678534fd (diff)
downloadangular.js-ec1c5dfaee32f9638cedd28bb96bbbecce9d0cf0.tar.bz2
fix(jqLite): .data()/.bind() memory leak
Since angular attaches scope/injector/controller into DOM it should clean up after itself. No need to complain about memory leaks, since they can only happened on detached DOM. Detached DOM would only be in tests, since in production the DOM would be attached to render tree and removal would automatically clear memory.
Diffstat (limited to 'src/ngMock/angular-mocks.js')
-rw-r--r--src/ngMock/angular-mocks.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js
index b0f6383a..8b5d100a 100644
--- a/src/ngMock/angular-mocks.js
+++ b/src/ngMock/angular-mocks.js
@@ -1526,6 +1526,20 @@ angular.mock.e2e = {};
angular.mock.e2e.$httpBackendDecorator = ['$delegate', '$browser', createHttpBackendMock];
+angular.mock.clearDataCache = function() {
+ var key,
+ cache = angular.element.cache;
+
+ for(key in cache) {
+ if (cache.hasOwnProperty(key)) {
+ var handle = cache[key].handle;
+
+ handle && angular.element(handle.elem).unbind();
+ delete cache[key];
+ }
+ }
+};
+
window.jstestdriver && (function(window) {
/**
@@ -1550,6 +1564,7 @@ window.jasmine && (function(window) {
var spec = getCurrentSpec();
spec.$injector = null;
spec.$modules = null;
+ angular.mock.clearDataCache();
});
function getCurrentSpec() {