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 #16164

Closes #16471
This commit is contained in:
Volker Braun
2018-02-26 09:38:03 +01:00
committed by George Kalpakas
parent 318e6ceea3
commit 2dfb6b4af6
+7 -1
View File
@@ -683,5 +683,11 @@ function markQStateExceptionHandled(state) {
state.pur = true;
}
function markQExceptionHandled(q) {
markQStateExceptionHandled(q.$$state);
// Built-in `$q` promises will always have a `$$state` property. This check is to allow
// overwriting `$q` with a different promise library (e.g. Bluebird + angular-bluebird-promises).
// (Currently, this is the only method that might be called with a promise, even if it is not
// created by the built-in `$q`.)
if (q.$$state) {
markQStateExceptionHandled(q.$$state);
}
}