diff options
| author | Vojta Jina | 2012-03-28 16:03:59 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-29 07:30:32 -0700 |
| commit | 6da355c3e1571b9a104fca2796df77a4194a28a2 (patch) | |
| tree | 8599843420c713b0a835e02311065fa984dcb1ee /test | |
| parent | f2106692b1ebf00aa5f8b2accd75f014b6cd4faa (diff) | |
| download | angular.js-6da355c3e1571b9a104fca2796df77a4194a28a2.tar.bz2 | |
refactor($compile): move methods of attr object into prototype
We have many instances of this object and we clone them as well (e.g. ng-repeat).
This should save some memory and performance as well.
Double prefixed private properties of attr object:
attr.$element -> attr.$$element
attr.$observers -> attr.$$observers
Update shallowCopy to not copy $$ properties and allow passing optional destination object.
Diffstat (limited to 'test')
| -rw-r--r-- | test/AngularSpec.js | 9 | ||||
| -rw-r--r-- | test/ng/compilerSpec.js | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js index da56449a..cf34305a 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -88,6 +88,15 @@ describe('angular', function() { expect(copy).toEqual(original); expect(copy.key).toBe(original.key); }); + + it('should not copy $$ properties nor prototype properties', function() { + var original = {$$some: true, $$: true}; + var clone = {}; + + expect(shallowCopy(original, clone)).toBe(clone); + expect(clone.$$some).toBeUndefined(); + expect(clone.$$).toBeUndefined(); + }); }); describe('elementHTML', function() { diff --git a/test/ng/compilerSpec.js b/test/ng/compilerSpec.js index fb5e99e6..55479396 100644 --- a/test/ng/compilerSpec.js +++ b/test/ng/compilerSpec.js @@ -166,7 +166,7 @@ describe('$compile', function() { compile: function(element, templateAttr) { expect(typeof templateAttr.$normalize).toBe('function'); expect(typeof templateAttr.$set).toBe('function'); - expect(isElement(templateAttr.$element)).toBeTruthy(); + expect(isElement(templateAttr.$$element)).toBeTruthy(); expect(element.text()).toEqual('unlinked'); expect(templateAttr.exp).toEqual('abc'); expect(templateAttr.aa).toEqual('A'); @@ -344,7 +344,7 @@ describe('$compile', function() { template: '<div class="log" style="width: 10px" high-log>Hello: <<CONTENT>></div>', compile: function(element, attr) { attr.$set('compiled', 'COMPILED'); - expect(element).toBe(attr.$element); + expect(element).toBe(attr.$$element); } })); $compileProvider.directive('append', valueFn({ @@ -352,7 +352,7 @@ describe('$compile', function() { template: '<div class="log" style="width: 10px" high-log>Hello: <<CONTENT>></div>', compile: function(element, attr) { attr.$set('compiled', 'COMPILED'); - expect(element).toBe(attr.$element); + expect(element).toBe(attr.$$element); } })); })); |
