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

Commit 3602c97

Browse files
committed
revert: chore($resource): Use shallow copy instead of angular.copy
1 parent acaac21 commit 3602c97

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/ngResource/resource.js

+3-22
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@ function lookupDottedPath(obj, path) {
2424
return obj;
2525
}
2626

27-
/**
28-
* Create a shallow copy of an object and clear other fields from the destination
29-
*/
30-
function shallowClearAndCopy(src, dst) {
31-
dst = dst || {};
32-
33-
angular.forEach(dst, function(value, key){
34-
delete dst[key];
35-
});
36-
37-
for (var key in src) {
38-
if (src.hasOwnProperty(key) && key.substr(0, 2) !== '$$') {
39-
dst[key] = src[key];
40-
}
41-
}
42-
43-
return dst;
44-
}
45-
4627
/**
4728
* @ngdoc overview
4829
* @name ngResource
@@ -412,7 +393,7 @@ angular.module('ngResource', ['ng']).
412393
}
413394

414395
function Resource(value){
415-
shallowClearAndCopy(value || {}, this);
396+
copy(value || {}, this);
416397
}
417398

418399
forEach(actions, function(action, name) {
@@ -484,7 +465,7 @@ angular.module('ngResource', ['ng']).
484465
if (data) {
485466
// Need to convert action.isArray to boolean in case it is undefined
486467
// jshint -W018
487-
if (angular.isArray(data) !== (!!action.isArray)) {
468+
if ( angular.isArray(data) !== (!!action.isArray) ) {
488469
throw $resourceMinErr('badcfg', 'Error in resource configuration. Expected ' +
489470
'response to contain an {0} but got an {1}',
490471
action.isArray?'array':'object', angular.isArray(data)?'array':'object');
@@ -496,7 +477,7 @@ angular.module('ngResource', ['ng']).
496477
value.push(new Resource(item));
497478
});
498479
} else {
499-
shallowClearAndCopy(data, value);
480+
copy(data, value);
500481
value.$promise = promise;
501482
}
502483
}

0 commit comments

Comments
 (0)