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

Commit 6e3b5a5

Browse files
committed
fix($parse): do not shallow-watch inputs to one-time intercepted expressions
1 parent f003d93 commit 6e3b5a5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/ng/parse.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,11 @@ function $ParseProvider() {
19771977
} else if (!interceptorFn.$stateful) {
19781978
// Treat interceptor like filters - assume non-stateful by default and use the inputsWatchDelegate
19791979
fn.$$watchDelegate = inputsWatchDelegate;
1980-
fn.inputs = (parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression]).map(function(e) {
1980+
fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression];
1981+
}
1982+
1983+
if (fn.inputs) {
1984+
fn.inputs = fn.inputs.map(function(e) {
19811985
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
19821986
// potentially non-pure interceptor function.
19831987
if (e.isPure === PURITY_RELATIVE) {

test/ng/directive/ngClassSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,20 @@ describe('ngClass', function() {
532532
})
533533
);
534534

535+
it('should support a one-time mixed literal-array/object variable', inject(function($rootScope, $compile) {
536+
element = $compile('<div ng-class="::[classVar1, classVar2]"></div>')($rootScope);
537+
538+
$rootScope.classVar1 = {orange: true};
539+
$rootScope.$digest();
540+
expect(element).toHaveClass('orange');
541+
542+
$rootScope.classVar1.orange = false;
543+
$rootScope.$digest();
544+
545+
expect(element).not.toHaveClass('orange');
546+
})
547+
);
548+
535549

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

0 commit comments

Comments
 (0)