Skip to content

Commit 87a4a71

Browse files
fix($compile): don't run unnecessary update to one-way bindings
The watch handler was triggering on its first invocation, even though its change had already been dealt with when setting up the binding. Closes angular#14546
1 parent 83dc068 commit 87a4a71

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/ng/compileSpec.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -4823,12 +4823,16 @@ describe('$compile', function() {
48234823
controller: function() {
48244824
component = this;
48254825
this.input = 'constructor';
4826+
log.push('constructor');
4827+
48264828
this.$onInit = function() {
48274829
this.input = '$onInit';
4830+
log.push('$onInit');
48284831
};
4832+
48294833
this.$onChanges = function(changes) {
48304834
if (changes.input) {
4831-
log.push(changes.input);
4835+
log.push(['$onChanges', changes.input]);
48324836
}
48334837
};
48344838
}
@@ -4841,6 +4845,11 @@ describe('$compile', function() {
48414845

48424846
expect($rootScope.name).toEqual('outer');
48434847
expect(component.input).toEqual('$onInit');
4848+
expect(log).toEqual([
4849+
'constructor',
4850+
['$onChanges', jasmine.objectContaining({ currentValue: 'outer' })],
4851+
'$onInit'
4852+
]);
48444853
});
48454854
});
48464855

0 commit comments

Comments
 (0)