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

Commit 6b4f2fc

Browse files
author
bluepnume
committed
fix($q): correctly set constructor on prototypes
This patch will correctly set `Promise.prototype.constructor` and `Deferred.prototype.constructor`. When prototype is set in the form `Foo.prototype = {x: y};`, the constructor will not be set correctly (as opposed to in the form `Foo.prototype.x = y;`. As such, it is necessary to manually add the constructor to the prototype in these cases.
1 parent f3b088a commit 6b4f2fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ng/q.js

+4
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ function qFactory(nextTick, exceptionHandler) {
271271
}
272272

273273
Promise.prototype = {
274+
constructor: Promise,
275+
274276
then: function(onFulfilled, onRejected, progressBack) {
275277
var result = new Deferred();
276278

@@ -340,6 +342,8 @@ function qFactory(nextTick, exceptionHandler) {
340342
}
341343

342344
Deferred.prototype = {
345+
constructor: Deferred,
346+
343347
resolve: function(val) {
344348
if (this.promise.$$state.status) return;
345349
if (val === this.promise) {

0 commit comments

Comments
 (0)