aboutsummaryrefslogtreecommitdiffstats
path: root/test/servicesSpec.js
diff options
context:
space:
mode:
authorIgor Minar2010-10-12 05:36:38 +0800
committerMisko Hevery2010-10-13 04:37:46 +0800
commit70ff7a2639fc55936854ad04a6242a700ae71a02 (patch)
treebe82632c890b9734d50cd681737b6bad9a689d91 /test/servicesSpec.js
parent7e47a2d016676f37287203f26689cce1ee1eaa0c (diff)
downloadangular.js-70ff7a2639fc55936854ad04a6242a700ae71a02.tar.bz2
fix memory leak caused by leftbehind $invalidWidgets references
- ng:switch should not clean up $invalidWidgets - $invalidWidgets should be clean up after each eval - add missing docs
Diffstat (limited to 'test/servicesSpec.js')
-rw-r--r--test/servicesSpec.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 04aebce7..c0101098 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -150,22 +150,27 @@ describe("service", function(){
describe("$invalidWidgets", function(){
it("should count number of invalid widgets", function(){
- var scope = compile('<input name="price" ng:required ng:validate="number"></input>').$init();
+ var scope = compile('<input name="price" ng:required ng:validate="number"></input>');
+ jqLite(document.body).append(scope.$element);
+ scope.$init();
expect(scope.$invalidWidgets.length).toEqual(1);
+
scope.price = 123;
scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(0);
+
scope.$element.remove();
scope.price = 'abc';
scope.$eval();
- expect(scope.$invalidWidgets.length).toEqual(1);
+ expect(scope.$invalidWidgets.length).toEqual(0);
jqLite(document.body).append(scope.$element);
- scope.$invalidWidgets.clearOrphans();
+ scope.price = 'abcd'; //force revalidation, maybe this should be done automatically?
+ scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(1);
jqLite(document.body).html('');
- scope.$invalidWidgets.clearOrphans();
+ scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(0);
});
});