Skip to content

Commit 2dfb6b4

Browse files
vbraungkalpak
authored andcommitted
fix($q): allow third-party promise libraries
For testing, it can be useful to overwrite `$q` with other promise implementions, such as Bluebird + angular-bluebird-promises. This broke in v1.6.x with "TypeError: Cannot set property 'pur' of undefined". Closes angular#16164 Closes angular#16471
1 parent 318e6ce commit 2dfb6b4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ng/q.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -683,5 +683,11 @@ function markQStateExceptionHandled(state) {
683683
state.pur = true;
684684
}
685685
function markQExceptionHandled(q) {
686-
markQStateExceptionHandled(q.$$state);
686+
// Built-in `$q` promises will always have a `$$state` property. This check is to allow
687+
// overwriting `$q` with a different promise library (e.g. Bluebird + angular-bluebird-promises).
688+
// (Currently, this is the only method that might be called with a promise, even if it is not
689+
// created by the built-in `$q`.)
690+
if (q.$$state) {
691+
markQStateExceptionHandled(q.$$state);
692+
}
687693
}

0 commit comments

Comments
 (0)