diff --git a/src/Angular.js b/src/Angular.js index 8daf1e417140..30fe419a9ff8 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -879,18 +879,38 @@ function shallowCopy(src, dst) { * @param {*} o2 Object or value to compare. * @returns {boolean} True if arguments are equal. */ -function equals(o1, o2) { +function equals(o1, o2, seen_list, comparisons) { if (o1 === o2) return true; if (o1 === null || o2 === null) return false; if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN var t1 = typeof o1, t2 = typeof o2, length, key, keySet; if (t1 == t2) { if (t1 == 'object') { + seen_list || (seen_list = []); + comparisons || (comparisons = []); + var i1 = seen_list.indexOf(o1); + var i2 = seen_list.indexOf(o2); + if (i1 != -1 && comparisons[i1].indexOf(o2) != -1) { + return true; + } else { + if (i1 == -1) { + seen_list.push(o1); + comparisons.push([o2]); + } else { + comparisons[i1].push(o2); + } + if (i2 == -1) { + seen_list.push(o2); + comparisons.push([o1]); + } else { + comparisons[i2].push(o1); + } + } if (isArray(o1)) { if (!isArray(o2)) return false; if ((length = o1.length) == o2.length) { for(key=0; key