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

Commit cc0c099

Browse files
committed
fix(parse): add support to Object.create(null) based bindings with the changes requested
1 parent dc5a43a commit cc0c099

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/ng/parse.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,10 @@ function getterFn(path, options, fullExp) {
946946
return fn;
947947
}
948948

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);
954953
}
955954

956955
///////////////////////////////////
@@ -1099,7 +1098,7 @@ function $ParseProvider() {
10991098
// attempt to convert the value to a primitive type
11001099
// TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can
11011100
// be cheaply dirty-checked
1102-
newValue = valueOfAgnostic(newValue);
1101+
newValue = getValueOf(newValue);
11031102

11041103
if (typeof newValue === 'object') {
11051104
// objects/arrays are not supported - deep-watching them would be too expensive
@@ -1126,7 +1125,7 @@ function $ParseProvider() {
11261125
var newInputValue = inputExpressions(scope);
11271126
if (!expressionInputDirtyCheck(newInputValue, oldInputValue)) {
11281127
lastResult = parsedExpression(scope);
1129-
oldInputValue = newInputValue && valueOfAgnostic(newInputValue);
1128+
oldInputValue = newInputValue && getValueOf(newInputValue);
11301129
}
11311130
return lastResult;
11321131
}, listener, objectEquality);
@@ -1143,7 +1142,7 @@ function $ParseProvider() {
11431142
for (var i = 0, ii = inputExpressions.length; i < ii; i++) {
11441143
var newInputValue = inputExpressions[i](scope);
11451144
if (changed || (changed = !expressionInputDirtyCheck(newInputValue, oldInputValueOfValues[i]))) {
1146-
oldInputValueOfValues[i] = newInputValue && valueOfAgnostic(newInputValue);
1145+
oldInputValueOfValues[i] = newInputValue && getValueOf(newInputValue);
11471146
}
11481147
}
11491148

0 commit comments

Comments
 (0)