mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
revert perf(Scope): remove the need for the extra watch in $watchGroup
This reverts commit 28540c804a.
This commit is contained in:
committed by
Caitlin Potter
parent
ce378f2582
commit
b3047b9dc9
@@ -2893,21 +2893,21 @@ describe('$compile', function() {
|
||||
|
||||
inject(function($rootScope) {
|
||||
compile('<div other-tpl-dir param1="::foo" param2="bar"></div>');
|
||||
expect(countWatches($rootScope)).toEqual(6); // 4 -> template watch group, 2 -> '='
|
||||
expect(countWatches($rootScope)).toEqual(7); // 5 -> template watch group, 2 -> '='
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(6);
|
||||
expect(countWatches($rootScope)).toEqual(7);
|
||||
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:;3:foo;4:');
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
expect(countWatches($rootScope)).toEqual(5);
|
||||
|
||||
$rootScope.foo = 'baz';
|
||||
$rootScope.bar = 'bar';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:bar;3:foo;4:bar');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.bar = 'baz';
|
||||
$rootScope.$digest();
|
||||
@@ -2927,21 +2927,21 @@ describe('$compile', function() {
|
||||
|
||||
inject(function($rootScope) {
|
||||
compile('<div other-tpl-dir param1="{{::foo}}" param2="{{bar}}"></div>');
|
||||
expect(countWatches($rootScope)).toEqual(6); // 4 -> template watch group, 2 -> {{ }}
|
||||
expect(countWatches($rootScope)).toEqual(7); // 5 -> template watch group, 2 -> {{ }}
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(4); // (- 2) -> bind-once in template
|
||||
expect(countWatches($rootScope)).toEqual(5); // (- 2) -> bind-once in template
|
||||
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.foo = 'baz';
|
||||
$rootScope.bar = 'bar';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:bar;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.bar = 'baz';
|
||||
$rootScope.$digest();
|
||||
@@ -2964,18 +2964,18 @@ describe('$compile', function() {
|
||||
compile('<div other-tpl-dir param1="::foo" param2="bar"></div>');
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(6); // 4 -> template watch group, 2 -> '='
|
||||
expect(countWatches($rootScope)).toEqual(7); // 5 -> template watch group, 2 -> '='
|
||||
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:;3:foo;4:');
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
expect(countWatches($rootScope)).toEqual(5);
|
||||
|
||||
$rootScope.foo = 'baz';
|
||||
$rootScope.bar = 'bar';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:bar;3:foo;4:bar');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.bar = 'baz';
|
||||
$rootScope.$digest();
|
||||
@@ -2998,18 +2998,18 @@ describe('$compile', function() {
|
||||
compile('<div other-tpl-dir param1="{{::foo}}" param2="{{bar}}"></div>');
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(4); // (4 - 2) -> template watch group, 2 -> {{ }}
|
||||
expect(countWatches($rootScope)).toEqual(5); // (5 - 2) -> template watch group, 2 -> {{ }}
|
||||
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.foo = 'baz';
|
||||
$rootScope.bar = 'bar';
|
||||
$rootScope.$digest();
|
||||
expect(element.html()).toBe('1:foo;2:bar;3:;4:');
|
||||
expect(countWatches($rootScope)).toEqual(3);
|
||||
expect(countWatches($rootScope)).toEqual(4);
|
||||
|
||||
$rootScope.bar = 'baz';
|
||||
$rootScope.$digest();
|
||||
|
||||
@@ -99,11 +99,11 @@ describe('ngBind*', function() {
|
||||
it('should one-time bind the expressions that start with ::', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-bind-template="{{::hello}} {{::name}}!"></div>')($rootScope);
|
||||
$rootScope.name = 'Misko';
|
||||
expect($rootScope.$$watchers.length).toEqual(2);
|
||||
expect($rootScope.$$watchers.length).toEqual(3);
|
||||
$rootScope.$digest();
|
||||
expect(element.hasClass('ng-binding')).toEqual(true);
|
||||
expect(element.text()).toEqual(' Misko!');
|
||||
expect($rootScope.$$watchers.length).toEqual(1);
|
||||
expect($rootScope.$$watchers.length).toEqual(2);
|
||||
$rootScope.hello = 'Hello';
|
||||
$rootScope.name = 'Lucas';
|
||||
$rootScope.$digest();
|
||||
|
||||
@@ -149,14 +149,14 @@ describe('Scope', function() {
|
||||
|
||||
it('should clean up stable watches from $watchGroup', inject(function($rootScope) {
|
||||
$rootScope.$watchGroup(['::foo', '::bar'], function() {});
|
||||
expect($rootScope.$$watchers.length).toEqual(2);
|
||||
expect($rootScope.$$watchers.length).toEqual(3);
|
||||
|
||||
$rootScope.$digest();
|
||||
expect($rootScope.$$watchers.length).toEqual(2);
|
||||
expect($rootScope.$$watchers.length).toEqual(3);
|
||||
|
||||
$rootScope.foo = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect($rootScope.$$watchers.length).toEqual(1);
|
||||
expect($rootScope.$$watchers.length).toEqual(2);
|
||||
|
||||
$rootScope.bar = 'bar';
|
||||
$rootScope.$digest();
|
||||
|
||||
Reference in New Issue
Block a user