@@ -946,11 +946,10 @@ function getterFn(path, options, fullExp) {
946
946
return fn ;
947
947
}
948
948
949
- function valueOfAgnostic ( value ) {
950
- if ( typeof value . valueOf !== 'function' ) {
951
- return Object . prototype . valueOf . call ( value ) ;
952
- }
953
- return value . valueOf ( ) ;
949
+ var objectValueOf = Object . prototype . valueOf ;
950
+
951
+ function getValueOf ( value ) {
952
+ return isFunction ( value . valueOf ) ? value . valueOf ( ) : objectValueOf ( value ) ;
954
953
}
955
954
956
955
///////////////////////////////////
@@ -1099,7 +1098,7 @@ function $ParseProvider() {
1099
1098
// attempt to convert the value to a primitive type
1100
1099
// TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can
1101
1100
// be cheaply dirty-checked
1102
- newValue = valueOfAgnostic ( newValue ) ;
1101
+ newValue = getValueOf ( newValue ) ;
1103
1102
1104
1103
if ( typeof newValue === 'object' ) {
1105
1104
// objects/arrays are not supported - deep-watching them would be too expensive
@@ -1126,7 +1125,7 @@ function $ParseProvider() {
1126
1125
var newInputValue = inputExpressions ( scope ) ;
1127
1126
if ( ! expressionInputDirtyCheck ( newInputValue , oldInputValue ) ) {
1128
1127
lastResult = parsedExpression ( scope ) ;
1129
- oldInputValue = newInputValue && valueOfAgnostic ( newInputValue ) ;
1128
+ oldInputValue = newInputValue && getValueOf ( newInputValue ) ;
1130
1129
}
1131
1130
return lastResult ;
1132
1131
} , listener , objectEquality ) ;
@@ -1143,7 +1142,7 @@ function $ParseProvider() {
1143
1142
for ( var i = 0 , ii = inputExpressions . length ; i < ii ; i ++ ) {
1144
1143
var newInputValue = inputExpressions [ i ] ( scope ) ;
1145
1144
if ( changed || ( changed = ! expressionInputDirtyCheck ( newInputValue , oldInputValueOfValues [ i ] ) ) ) {
1146
- oldInputValueOfValues [ i ] = newInputValue && valueOfAgnostic ( newInputValue ) ;
1145
+ oldInputValueOfValues [ i ] = newInputValue && getValueOf ( newInputValue ) ;
1147
1146
}
1148
1147
}
1149
1148
0 commit comments