@@ -81,6 +81,27 @@ function noConflict() {
8181 return a ;
8282}
8383
84+ /**
85+ * @private
86+ * @param {* } obj
87+ * @return {boolean } Returns true if `obj` is an array or array-like object (NodeList, Arguments, ...)
88+ */
89+ function isArrayLike ( obj ) {
90+ if ( ! obj || ( typeof obj . length !== 'number' ) ) return false ;
91+
92+ // We have on object which has length property. Should we treat it as array?
93+ if ( typeof obj . hasOwnProperty != 'function' &&
94+ typeof obj . constructor != 'function' ) {
95+ // This is here for IE8: it is a bogus object treat it as array;
96+ return true ;
97+ } else {
98+ return obj instanceof JQLite || // JQLite
99+ ( jQuery && obj instanceof jQuery ) || // jQuery
100+ toString . call ( obj ) !== '[object Object]' || // some browser native object
101+ typeof obj . callee === 'function' ; // arguments (on IE8 looks like regular obj)
102+ }
103+ }
104+
84105/**
85106 * @ngdoc function
86107 * @name angular.forEach
@@ -108,30 +129,6 @@ function noConflict() {
108129 * @param {Object= } context Object to become context (`this`) for the iterator function.
109130 * @returns {Object|Array } Reference to `obj`.
110131 */
111-
112-
113- /**
114- * @private
115- * @param {* } obj
116- * @return {boolean } Returns true if `obj` is an array or array-like object (NodeList, Arguments, ...)
117- */
118- function isArrayLike ( obj ) {
119- if ( ! obj || ( typeof obj . length !== 'number' ) ) return false ;
120-
121- // We have on object which has length property. Should we treat it as array?
122- if ( typeof obj . hasOwnProperty != 'function' &&
123- typeof obj . constructor != 'function' ) {
124- // This is here for IE8: it is a bogus object treat it as array;
125- return true ;
126- } else {
127- return obj instanceof JQLite || // JQLite
128- ( jQuery && obj instanceof jQuery ) || // jQuery
129- toString . call ( obj ) !== '[object Object]' || // some browser native object
130- typeof obj . callee === 'function' ; // arguments (on IE8 looks like regular obj)
131- }
132- }
133-
134-
135132function forEach ( obj , iterator , context ) {
136133 var key ;
137134 if ( obj ) {
@@ -215,6 +212,21 @@ function nextUid() {
215212 return uid . join ( '' ) ;
216213}
217214
215+
216+ /**
217+ * Set or clear the hashkey for an object.
218+ * @param obj object
219+ * @param h the hashkey (!truthy to delete the hashkey)
220+ */
221+ function setHashKey ( obj , h ) {
222+ if ( h ) {
223+ obj . $$hashKey = h ;
224+ }
225+ else {
226+ delete obj . $$hashKey ;
227+ }
228+ }
229+
218230/**
219231 * @ngdoc function
220232 * @name angular.extend
@@ -228,13 +240,16 @@ function nextUid() {
228240 * @param {...Object } src Source object(s).
229241 */
230242function extend ( dst ) {
243+ var h = dst . $$hashKey ;
231244 forEach ( arguments , function ( obj ) {
232245 if ( obj !== dst ) {
233246 forEach ( obj , function ( value , key ) {
234247 dst [ key ] = value ;
235248 } ) ;
236249 }
237250 } ) ;
251+
252+ setHashKey ( dst , h ) ;
238253 return dst ;
239254}
240255
@@ -594,12 +609,14 @@ function copy(source, destination){
594609 destination . push ( copy ( source [ i ] ) ) ;
595610 }
596611 } else {
612+ var h = destination . $$hashKey ;
597613 forEach ( destination , function ( value , key ) {
598614 delete destination [ key ] ;
599615 } ) ;
600616 for ( var key in source ) {
601617 destination [ key ] = copy ( source [ key ] ) ;
602618 }
619+ setHashKey ( destination , h ) ;
603620 }
604621 }
605622 return destination ;
0 commit comments