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

fix($parse): do not shallow-watch inputs to one-time intercepted expressions #16059

Merged
merged 1 commit into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,11 @@ function $ParseProvider() {
} else if (!interceptorFn.$stateful) {
// Treat interceptor like filters - assume non-stateful by default and use the inputsWatchDelegate
fn.$$watchDelegate = inputsWatchDelegate;
fn.inputs = (parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression]).map(function(e) {
fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression];
}

if (fn.inputs) {
fn.inputs = fn.inputs.map(function(e) {
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
// potentially non-pure interceptor function.
if (e.isPure === PURITY_RELATIVE) {
Expand Down
14 changes: 14 additions & 0 deletions test/ng/directive/ngClassSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,20 @@ describe('ngClass', function() {
})
);

it('should support a one-time mixed literal-array/object variable', inject(function($rootScope, $compile) {
element = $compile('<div ng-class="::[classVar1, classVar2]"></div>')($rootScope);

$rootScope.classVar1 = {orange: true};
$rootScope.$digest();
expect(element).toHaveClass('orange');

$rootScope.classVar1.orange = false;
$rootScope.$digest();

expect(element).not.toHaveClass('orange');
})
);


it('should do value stabilization as expected when one-time binding',
inject(function($rootScope, $compile) {
Expand Down