mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Core: Re-throw errors that happened in callbacks wrapped in jQuery ready
Also, expose jQuery.readyException that allows to overwrite the default ready error handler. Fixes gh-3174 Closes gh-3210
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
define( [
|
||||
"../core",
|
||||
"../var/document",
|
||||
"../core/readyException",
|
||||
"../deferred"
|
||||
], function( jQuery, document ) {
|
||||
|
||||
@@ -11,7 +12,15 @@ var readyList = jQuery.Deferred();
|
||||
|
||||
jQuery.fn.ready = function( fn ) {
|
||||
|
||||
readyList.then( fn );
|
||||
readyList
|
||||
.then( fn )
|
||||
|
||||
// Wrap jQuery.readyException in a function so that the lookup
|
||||
// happens at the time of error handling instead of callback
|
||||
// registration.
|
||||
.catch( function( error ) {
|
||||
jQuery.readyException( error );
|
||||
} );
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
13
src/core/readyException.js
Normal file
13
src/core/readyException.js
Normal file
@@ -0,0 +1,13 @@
|
||||
define( [
|
||||
"../core"
|
||||
], function( jQuery ) {
|
||||
|
||||
"use strict";
|
||||
|
||||
jQuery.readyException = function( error ) {
|
||||
window.setTimeout( function() {
|
||||
throw error;
|
||||
} );
|
||||
};
|
||||
|
||||
} );
|
||||
Reference in New Issue
Block a user