diff --git a/src/ng/parse.js b/src/ng/parse.js index 7edc67560fde..a8ec5c8a3b8f 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -1906,13 +1906,14 @@ function $ParseProvider() { function addInterceptor(parsedExpression, interceptorFn) { if (!interceptorFn) return parsedExpression; var watchDelegate = parsedExpression.$$watchDelegate; + var useInputs = false; var regularWatch = watchDelegate !== oneTimeLiteralWatchDelegate && watchDelegate !== oneTimeWatchDelegate; var fn = regularWatch ? function regularInterceptedExpression(scope, locals, assign, inputs) { - var value = parsedExpression(scope, locals, assign, inputs); + var value = useInputs && inputs ? inputs[0] : parsedExpression(scope, locals, assign, inputs); return interceptorFn(value, scope, locals); } : function oneTimeInterceptedExpression(scope, locals, assign, inputs) { var value = parsedExpression(scope, locals, assign, inputs); @@ -1930,6 +1931,7 @@ function $ParseProvider() { // If there is an interceptor, but no watchDelegate then treat the interceptor like // we treat filters - it is assumed to be a pure function unless flagged with $stateful fn.$$watchDelegate = inputsWatchDelegate; + useInputs = !parsedExpression.inputs; fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression]; } diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 54942dfdd1e7..62211cf2c10d 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -947,6 +947,14 @@ describe('$compile', function() { expect(child).toHaveClass('log'); // merged from replace directive template })); + it('should interpolate the values once per digest', + inject(function($compile, $rootScope, log) { + element = $compile('
{{log("A")}} foo {{log("B")}}
')($rootScope); + $rootScope.log = log; + $rootScope.$digest(); + expect(log).toEqual('A; B; A; B'); + })); + it('should update references to replaced jQuery context', function() { module(function($compileProvider) { $compileProvider.directive('foo', function() {