diff options
| author | Igor Minar | 2010-10-12 05:36:38 +0800 | 
|---|---|---|
| committer | Misko Hevery | 2010-10-13 04:37:46 +0800 | 
| commit | 70ff7a2639fc55936854ad04a6242a700ae71a02 (patch) | |
| tree | be82632c890b9734d50cd681737b6bad9a689d91 /test/widgetsSpec.js | |
| parent | 7e47a2d016676f37287203f26689cce1ee1eaa0c (diff) | |
| download | angular.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/widgetsSpec.js')
| -rw-r--r-- | test/widgetsSpec.js | 18 | 
1 files changed, 9 insertions, 9 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index d2a39535..80acc928 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -5,10 +5,11 @@ describe("widget", function(){      scope = null;      element = null;      var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget); -    compile = function(html, before) { +    compile = function(html, before, parent) {        element = jqLite(html);        scope = compiler.compile(element)(element);        (before||noop).apply(scope); +      if (parent) parent.append(element);        scope.$init();      };    }); @@ -163,7 +164,8 @@ describe("widget", function(){        describe("ng:validate", function(){          it("should process ng:validate", function(){ -          compile('<input type="text" name="price" value="abc" ng:validate="number"/>'); +          compile('<input type="text" name="price" value="abc" ng:validate="number"/>', +                  undefined, jqLite(document.body));            expect(element.hasClass('ng-validation-error')).toBeTruthy();            expect(element.attr('ng-validation-error')).toEqual('Not a number'); @@ -217,7 +219,7 @@ describe("widget", function(){      });      it("should process ng:required", function(){ -      compile('<input type="text" name="price" ng:required/>'); +      compile('<input type="text" name="price" ng:required/>', undefined, jqLite(document.body));        expect(element.hasClass('ng-validation-error')).toBeTruthy();        expect(element.attr('ng-validation-error')).toEqual('Required'); @@ -233,7 +235,8 @@ describe("widget", function(){      });      it('should allow conditions on ng:required', function() { -      compile('<input type="text" name="price" ng:required="ineedz"/>'); +      compile('<input type="text" name="price" ng:required="ineedz"/>', +              undefined, jqLite(document.body));        scope.$set('ineedz', false);        scope.$eval();        expect(element.hasClass('ng-validation-error')).toBeFalsy(); @@ -372,7 +375,8 @@ describe("widget", function(){          compile(              '<select name="selection" ng:required>' +                '<option value="{{$index}}" ng:repeat="opt in options">{{opt}}</option>' + -            '</select>'); +            '</select>', +            undefined, jqLite(document.body));          scope.selection = 1;          scope.options = ['one', 'two'];          scope.$eval(); @@ -459,13 +463,9 @@ describe("widget", function(){        var scope = angular.compile('<ng:switch on="url" change="name=\'works\'"><div ng:switch-when="a">{{name}}</div></ng:switch>');        var cleared = false;        scope.url = 'a'; -      scope.$invalidWidgets = {clearOrphans: function(){ -        cleared = true; -      }};        scope.$init();        expect(scope.name).toEqual(undefined);        expect(scope.$element.text()).toEqual('works'); -      expect(cleared).toEqual(true);      });    });  | 
