Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix+perf($parse): allow watching array/object literal values, disable deep watch for one-way bindings #15301

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3522,7 +3522,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
recordChanges(scopeName, newValue, oldValue);
destination[scopeName] = newValue;
}, deepWatch);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep watching never happens, but we still have a variable named deepWatch. Isn't it a bit misleading?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so let's change deepWatch to isLiteral.


removeWatchCollection.push(removeWatch);
break;
Expand Down
4 changes: 2 additions & 2 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5676,7 +5676,7 @@ describe('$compile', function() {
}));


it('should deep-watch array literals', inject(function() {
it('should watch input values to array literals', inject(function() {
$rootScope.name = 'georgios';
$rootScope.obj = {name: 'pete'};
compile('<div><span my-component ow-ref="[{name: name}, obj]">');
Expand All @@ -5690,7 +5690,7 @@ describe('$compile', function() {
}));


it('should deep-watch object literals', inject(function() {
it('should watch input values object literals', inject(function() {
$rootScope.name = 'georgios';
$rootScope.obj = {name: 'pete'};
compile('<div><span my-component ow-ref="{name: name, item: obj}">');
Expand Down