Created
November 4, 2011 01:15
-
-
Save omni5cience/1338423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1aac15aadd1c6231854fc38dfa25f6d3ac920d4e Mon Sep 17 00:00:00 2001 | |
From: Sam Epstein <same008@gmail.com> | |
Date: Thu, 3 Nov 2011 21:13:55 -0400 | |
Subject: [PATCH] First pass at jQuery.later | |
--- | |
src/core.js | 10 ++++++++++ | |
test/unit/core.js | 13 +++++++++++++ | |
2 files changed, 23 insertions(+), 0 deletions(-) | |
diff --git a/src/core.js b/src/core.js | |
index 9e5a552..e6d5f50 100644 | |
--- a/src/core.js | |
+++ b/src/core.js | |
@@ -836,6 +836,16 @@ jQuery.extend({ | |
return ( new Date() ).getTime(); | |
}, | |
+ later: function( fn ) { | |
+ if ( jQuery.isFunction( window.msSetImmediate ) ) { | |
+ msSetImmediate( fn ); | |
+ } else if ( jQuery.isFunction( window.setImmediate ) ) { | |
+ setImmediate( fn ); | |
+ } else { | |
+ setTimeout( fn, 0 ); | |
+ } | |
+ }, | |
+ | |
// Use of jQuery.browser is frowned upon. | |
// More details: http://docs.jquery.com/Utilities/jQuery.browser | |
uaMatch: function( ua ) { | |
diff --git a/test/unit/core.js b/test/unit/core.js | |
index 0756e79..7e15a33 100644 | |
--- a/test/unit/core.js | |
+++ b/test/unit/core.js | |
@@ -1260,3 +1260,16 @@ test("jQuery.camelCase()", function() { | |
equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val ); | |
}); | |
}); | |
+ | |
+test("jQuery.later()", function() { | |
+ | |
+ stop(50); | |
+ | |
+ expect(1); | |
+ | |
+ jQuery.later( function() { | |
+ ok(true, "Function called"); | |
+ start(); | |
+ }); | |
+ | |
+}); | |
-- | |
1.7.4.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment