diff --git a/src/Angular.js b/src/Angular.js index 905421e0fd03..5da0e1e4498b 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -766,7 +766,7 @@ function copy(source, destination, stackSource, stackDest) { } else if (isRegExp(source)) { destination = new RegExp(source.source); } else if (isObject(source)) { - destination = copy(source, {}, stackSource, stackDest); + destination = copy(source, Object.create(Object.getPrototypeOf(source)), stackSource, stackDest); } } } else { diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 472ae6269913..cfeef7988c12 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -160,6 +160,15 @@ describe('angular', function() { expect(aCopy).toBe(aCopy.self); expect(aCopy.selfs[2]).not.toBe(a.selfs[2]); }); + + it('should retain the source prototype on the destination', function () { + function A() {} + var a = new A(); + var a_copy = copy(a); + + expect(a instanceof A).toBe(true); + expect(a_copy instanceof A).toBe(true); + }); }); describe("extend", function() {