@@ -169,6 +169,7 @@ function $InterpolateProvider() {
169
169
if ( ! mustHaveExpression || hasInterpolation ) {
170
170
var concat = new Array ( parts . length ) ,
171
171
expressions = { } ;
172
+
172
173
forEach ( parts , function ( value , index ) {
173
174
if ( isFunction ( value ) ) {
174
175
expressions [ index ] = value ;
@@ -177,49 +178,51 @@ function $InterpolateProvider() {
177
178
concat [ index ] = value ;
178
179
}
179
180
} ) ;
181
+
180
182
// computes all the interpolations and returns the resulting string
181
- // a specific index might already be computed (cz of the scope's dirty-checking),
183
+ // a specific index might already be computed (thanks to the scope's dirty-checking),
182
184
// and so its expression shouldn't be executed a 2nd time
183
185
// also populates the lastValues of custom watchers for internal dirty-checking
184
- var getTextValue = function ( scope , computedIndex , computedValue , lastValues ) {
186
+ //TODO(i): rename to getConcatValue
187
+ var getTextValue = function ( scope , computedIndex , computedValue , lastValues ) {
185
188
try {
189
+
186
190
forEach ( expressions , function ( expression , index ) {
187
- concat [ index ] = index == computedIndex
191
+ concat [ index ] = ( index === computedIndex )
188
192
? computedValue
189
193
: getStringValue ( expression ( scope ) ) ;
190
194
191
195
if ( lastValues ) lastValues [ index ] = concat [ index ] ;
192
196
} ) ;
193
197
return concat . join ( '' ) ;
194
- }
195
- catch ( err ) {
198
+
199
+ } catch ( err ) {
196
200
var newErr = $interpolateMinErr ( 'interr' , "Can't interpolate: {0}\n{1}" , text ,
197
201
err . toString ( ) ) ;
198
202
$exceptionHandler ( newErr ) ;
199
203
}
200
204
} ;
201
- var getStringValue = function ( value ) {
205
+
206
+ var getStringValue = function ( value ) {
202
207
value = trustedContext
203
208
? $sce . getTrusted ( trustedContext , value )
204
209
: $sce . valueOf ( value ) ;
205
210
206
- if ( value === null || isUndefined ( value ) ) {
211
+ if ( value == null ) {
207
212
return '' ;
208
213
}
209
214
return isString ( value ) ? value : toJson ( value ) ;
210
215
} ;
211
216
212
- fn = function ( scope ) {
213
- return getTextValue ( scope ) ;
214
- } ;
217
+ fn = getTextValue ;
215
218
fn . exp = text ;
216
219
fn . parts = parts ;
217
220
218
221
// watches each interpolation separately for performance
219
- fn . $$beWatched = function ( scope , origListener , objectEquality ) {
222
+ fn . $$beWatched = function ( scope , origListener , objectEquality ) {
220
223
var lastTextValue , lastValues = { } , watchersRm = [ ] ;
221
224
222
- forEach ( expressions , function ( expression , index ) {
225
+ forEach ( expressions , function ( expression , index ) {
223
226
watchersRm . push ( scope . $watch ( function watchInterpolatedExpr ( scope ) {
224
227
try {
225
228
return getStringValue ( expression ( scope ) ) ;
0 commit comments