aboutsummaryrefslogtreecommitdiffstats
path: root/src/deferred.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-03-14 22:32:57 +0100
committerGitHub <noreply@github.com>2023-03-14 22:32:57 +0100
commitcca7118658a074771fb3598145e78ca39b93c20d (patch)
treefb13557e2e3015ea48c569631b806a4bb9b2d801 /src/deferred.js
parent3b7bf19998b8373a402f8f2c933fbbe0c112f0ed (diff)
downloadjquery-cca7118658a074771fb3598145e78ca39b93c20d.tar.gz
jquery-cca7118658a074771fb3598145e78ca39b93c20d.zip
Deferred: Rename `getStackHook` to `getErrorHook` (3.x version)
Rename `jQuery.Deferred.getStackHook` to `jQuery.Deferred.getErrorHook` to indicate passing an error instance is usually a better choice - it works with source maps while a raw stack generally does not. In jQuery `3.7.0`, we'll keep both names, marking the old one as deprecated. In jQuery `4.0.0` we'll just keep the new one. This change implements the `3.7.0` version; PR gh-5211 implements the `4.0.0` one. Fixes gh-5201 Closes gh-5212 Ref gh-5211
Diffstat (limited to 'src/deferred.js')
-rw-r--r--src/deferred.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/deferred.js b/src/deferred.js
index 439653f58..5e390b7f6 100644
--- a/src/deferred.js
+++ b/src/deferred.js
@@ -194,7 +194,7 @@ jQuery.extend( {
if ( jQuery.Deferred.exceptionHook ) {
jQuery.Deferred.exceptionHook( e,
- process.stackTrace );
+ process.error );
}
// Support: Promises/A+ section 2.3.3.3.4.1
@@ -222,10 +222,17 @@ jQuery.extend( {
process();
} else {
- // Call an optional hook to record the stack, in case of exception
+ // Call an optional hook to record the error, in case of exception
// since it's otherwise lost when execution goes async
- if ( jQuery.Deferred.getStackHook ) {
- process.stackTrace = jQuery.Deferred.getStackHook();
+ if ( jQuery.Deferred.getErrorHook ) {
+ process.error = jQuery.Deferred.getErrorHook();
+
+ // The deprecated alias of the above. While the name suggests
+ // returning the stack, not an error instance, jQuery just passes
+ // it directly to `console.warn` so both will work; an instance
+ // just better cooperates with source maps.
+ } else if ( jQuery.Deferred.getStackHook ) {
+ process.error = jQuery.Deferred.getStackHook();
}
window.setTimeout( process );
}