Skip to content

Commit 842958e

Browse files
committedJun 17, 2015
Core: Switch from modules to just window.setTimeout etc.
Using modules for window.setTimeout etc. made those functions cached and disabled Sinon mocking, making effects tests fail. Just writing window.setTimeout directly is smaller anyway.
1 parent 219c749 commit 842958e

File tree

9 files changed

+14
-37
lines changed

9 files changed

+14
-37
lines changed
 

‎src/ajax.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ define([
22
"./core",
33
"./var/document",
44
"./var/rnotwhite",
5-
"./var/setTimeout",
6-
"./var/clearTimeout",
75
"./ajax/var/location",
86
"./ajax/var/nonce",
97
"./ajax/var/rquery",
108
"./core/init",
119
"./ajax/parseJSON",
1210
"./ajax/parseXML",
1311
"./deferred"
14-
], function( jQuery, document, rnotwhite, setTimeout, clearTimeout,
15-
location, nonce, rquery ) {
12+
], function( jQuery, document, rnotwhite, location, nonce, rquery ) {
1613

1714
var
1815
rhash = /#.*$/,
@@ -645,7 +642,7 @@ jQuery.extend({
645642

646643
// Timeout
647644
if ( s.async && s.timeout > 0 ) {
648-
timeoutTimer = setTimeout(function() {
645+
timeoutTimer = window.setTimeout(function() {
649646
jqXHR.abort("timeout");
650647
}, s.timeout );
651648
}
@@ -679,7 +676,7 @@ jQuery.extend({
679676

680677
// Clear timeout if it exists
681678
if ( timeoutTimer ) {
682-
clearTimeout( timeoutTimer );
679+
window.clearTimeout( timeoutTimer );
683680
}
684681

685682
// Dereference transport for early garbage collection

‎src/core/ready.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
define([
22
"../core",
33
"../var/document",
4-
"../var/setTimeout",
54
"../deferred"
6-
], function( jQuery, document, setTimeout ) {
5+
], function( jQuery, document ) {
76

87
// The deferred used on DOM ready
98
var readyList;
@@ -74,7 +73,7 @@ jQuery.ready.promise = function( obj ) {
7473
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
7574
if ( document.readyState === "complete" ) {
7675
// Handle it asynchronously to allow scripts the opportunity to delay ready
77-
setTimeout( jQuery.ready );
76+
window.setTimeout( jQuery.ready );
7877

7978
} else {
8079

‎src/deferred.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
define([
22
"./core",
33
"./var/slice",
4-
"./var/setTimeout",
54
"./callbacks"
6-
], function( jQuery, slice, setTimeout ) {
5+
], function( jQuery, slice ) {
76

87
function Identity( v ) {
98
return v;
@@ -174,7 +173,7 @@ jQuery.extend({
174173
if ( depth ) {
175174
process();
176175
} else {
177-
setTimeout( process );
176+
window.setTimeout( process );
178177
}
179178
};
180179
}

‎src/effects.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ define([
22
"./core",
33
"./var/document",
44
"./var/rcssNum",
5-
"./var/setInterval",
6-
"./var/clearInterval",
7-
"./var/setTimeout",
85
"./css/var/cssExpand",
96
"./css/var/isHidden",
107
"./css/var/swap",
@@ -19,8 +16,7 @@ define([
1916
"./manipulation",
2017
"./css",
2118
"./effects/Tween"
22-
], function( jQuery, document, rcssNum, setInterval, clearInterval, setTimeout,
23-
cssExpand, isHidden, swap, adjustCSS, dataPriv, showHide ) {
19+
], function( jQuery, document, rcssNum, cssExpand, isHidden, swap, adjustCSS, dataPriv, showHide ) {
2420

2521
var
2622
fxNow, timerId,
@@ -44,7 +40,7 @@ function raf() {
4440

4541
// Animations created synchronously will run synchronously
4642
function createFxNow() {
47-
setTimeout(function() {
43+
window.setTimeout(function() {
4844
fxNow = undefined;
4945
});
5046
return ( fxNow = jQuery.now() );
@@ -638,15 +634,15 @@ jQuery.fx.start = function() {
638634
if ( !timerId ) {
639635
timerId = window.requestAnimationFrame ?
640636
window.requestAnimationFrame( raf ) :
641-
setInterval( jQuery.fx.tick, jQuery.fx.interval );
637+
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
642638
}
643639
};
644640

645641
jQuery.fx.stop = function() {
646642
if ( window.cancelAnimationFrame ) {
647643
window.cancelAnimationFrame( timerId );
648644
} else {
649-
clearInterval( timerId );
645+
window.clearInterval( timerId );
650646
}
651647

652648
timerId = null;

‎src/queue/delay.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
define([
22
"../core",
3-
"../var/setTimeout",
4-
"../var/clearTimeout",
53
"../queue",
64
"../effects" // Delay is optional because of this dependency
7-
], function( jQuery, setTimeout, clearTimeout ) {
5+
], function( jQuery ) {
86

97
// Based off of the plugin by Clint Helfers, with permission.
108
// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
@@ -13,9 +11,9 @@ jQuery.fn.delay = function( time, type ) {
1311
type = type || "fx";
1412

1513
return this.queue( type, function( next, hooks ) {
16-
var timeout = setTimeout( next, time );
14+
var timeout = window.setTimeout( next, time );
1715
hooks.stop = function() {
18-
clearTimeout( timeout );
16+
window.clearTimeout( timeout );
1917
};
2018
});
2119
};

‎src/var/clearInterval.js

-3
This file was deleted.

‎src/var/clearTimeout.js

-3
This file was deleted.

‎src/var/setInterval.js

-3
This file was deleted.

‎src/var/setTimeout.js

-3
This file was deleted.

0 commit comments

Comments
 (0)