@@ -946,6 +946,13 @@ 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 ( ) ;
954
+ }
955
+
949
956
///////////////////////////////////
950
957
951
958
/**
@@ -1092,7 +1099,7 @@ function $ParseProvider() {
1092
1099
// attempt to convert the value to a primitive type
1093
1100
// TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can
1094
1101
// be cheaply dirty-checked
1095
- newValue = valueOfObject . call ( newValue ) ;
1102
+ newValue = valueOfAgnostic ( newValue ) ;
1096
1103
1097
1104
if ( typeof newValue === 'object' ) {
1098
1105
// objects/arrays are not supported - deep-watching them would be too expensive
@@ -1119,7 +1126,7 @@ function $ParseProvider() {
1119
1126
var newInputValue = inputExpressions ( scope ) ;
1120
1127
if ( ! expressionInputDirtyCheck ( newInputValue , oldInputValue ) ) {
1121
1128
lastResult = parsedExpression ( scope ) ;
1122
- oldInputValue = newInputValue && valueOfObject . call ( newInputValue ) ;
1129
+ oldInputValue = newInputValue && valueOfAgnostic ( newInputValue ) ;
1123
1130
}
1124
1131
return lastResult ;
1125
1132
} , listener , objectEquality ) ;
@@ -1136,7 +1143,7 @@ function $ParseProvider() {
1136
1143
for ( var i = 0 , ii = inputExpressions . length ; i < ii ; i ++ ) {
1137
1144
var newInputValue = inputExpressions [ i ] ( scope ) ;
1138
1145
if ( changed || ( changed = ! expressionInputDirtyCheck ( newInputValue , oldInputValueOfValues [ i ] ) ) ) {
1139
- oldInputValueOfValues [ i ] = newInputValue && valueOfObject . call ( newInputValue ) ;
1146
+ oldInputValueOfValues [ i ] = newInputValue && valueOfAgnostic ( newInputValue ) ;
1140
1147
}
1141
1148
}
1142
1149
0 commit comments