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

fix(parse): dirty checking support for objects with null prototype #9568

Closed
wants to merge 8 commits into from
Prev Previous commit
Next Next commit
pr updated with newly cached method on Angular.js
HeberLZ committed Oct 10, 2014
commit 91235364e548e5ce35387832bda3a1b00f86935f
9 changes: 3 additions & 6 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
@@ -1092,8 +1092,7 @@ function $ParseProvider() {
// attempt to convert the value to a primitive type
// TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can
// be cheaply dirty-checked
typeof newValue.valueOf !== 'function' && (newValue = Object.valueOf.apply(newValue)) ||
(newValue = newValue.valueOf());
newValue = valueOfObject.call(newValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right. Won't this always use Object.prototype's method ?
The point is to only use it when there is no newValue.valueOf() method.
(The same goes for the other changes below.)


if (typeof newValue === 'object') {
// objects/arrays are not supported - deep-watching them would be too expensive
@@ -1120,8 +1119,7 @@ function $ParseProvider() {
var newInputValue = inputExpressions(scope);
if (!expressionInputDirtyCheck(newInputValue, oldInputValue)) {
lastResult = parsedExpression(scope);
oldInputValue = newInputValue && typeof newInputValue.valueOf !== 'function' &&
Object.valueOf.apply(newInputValue) || newInputValue.valueOf();
oldInputValue = newInputValue && valueOfObject.call(newInputValue);
}
return lastResult;
}, listener, objectEquality);
@@ -1138,8 +1136,7 @@ function $ParseProvider() {
for (var i = 0, ii = inputExpressions.length; i < ii; i++) {
var newInputValue = inputExpressions[i](scope);
if (changed || (changed = !expressionInputDirtyCheck(newInputValue, oldInputValueOfValues[i]))) {
oldInputValueOfValues[i] = newInputValue && typeof newInputValue.valueOf !== 'function' &&
Object.valueOf.apply(newInputValue) || newInputValue.valueOf();
oldInputValueOfValues[i] = newInputValue && valueOfObject.call(newInputValue);
}
}