Merge "re-enable testapi auto update"
[releng.git] / utils / test / testapi / 3rd_party / static / testapi-ui / assets / lib / jquery / src / core / ready-no-deferred.js
1 define( [
2         "../core",
3         "../var/document"
4 ], function( jQuery, document ) {
5
6 "use strict";
7
8 var readyCallbacks = [],
9         whenReady = function( fn ) {
10                 readyCallbacks.push( fn );
11         },
12         executeReady = function( fn ) {
13
14                 // Prevent errors from freezing future callback execution (gh-1823)
15                 // Not backwards-compatible as this does not execute sync
16                 window.setTimeout( function() {
17                         fn.call( document, jQuery );
18                 } );
19         };
20
21 jQuery.fn.ready = function( fn ) {
22         whenReady( fn );
23         return this;
24 };
25
26 jQuery.extend( {
27
28         // Is the DOM ready to be used? Set to true once it occurs.
29         isReady: false,
30
31         // A counter to track how many items to wait for before
32         // the ready event fires. See #6781
33         readyWait: 1,
34
35         ready: function( wait ) {
36
37                 // Abort if there are pending holds or we're already ready
38                 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
39                         return;
40                 }
41
42                 // Remember that the DOM is ready
43                 jQuery.isReady = true;
44
45                 // If a normal DOM Ready event fired, decrement, and wait if need be
46                 if ( wait !== true && --jQuery.readyWait > 0 ) {
47                         return;
48                 }
49
50                 whenReady = function( fn ) {
51                         readyCallbacks.push( fn );
52
53                         while ( readyCallbacks.length ) {
54                                 fn = readyCallbacks.shift();
55                                 if ( jQuery.isFunction( fn ) ) {
56                                         executeReady( fn );
57                                 }
58                         }
59                 };
60
61                 whenReady();
62         }
63 } );
64
65 // Make jQuery.ready Promise consumable (gh-1778)
66 jQuery.ready.then = jQuery.fn.ready;
67
68 /**
69  * The ready event handler and self cleanup method
70  */
71 function completed() {
72         document.removeEventListener( "DOMContentLoaded", completed );
73         window.removeEventListener( "load", completed );
74         jQuery.ready();
75 }
76
77 // Catch cases where $(document).ready() is called
78 // after the browser event has already occurred.
79 // Support: IE9-10 only
80 // Older IE sometimes signals "interactive" too soon
81 if ( document.readyState === "complete" ||
82         ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
83
84         // Handle it asynchronously to allow scripts the opportunity to delay ready
85         window.setTimeout( jQuery.ready );
86
87 } else {
88
89         // Use the handy event callback
90         document.addEventListener( "DOMContentLoaded", completed );
91
92         // A fallback to window.onload, that will always work
93         window.addEventListener( "load", completed );
94 }
95
96 } );