aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2014-03-03 22:04:23 -0500
committerDave Methvin <dave.methvin@gmail.com>2014-03-04 21:50:43 -0500
commit80e3dfa6bac3340aafcc87e956e1c461ba570e68 (patch)
treeaa83770446d2c5eb428b5cb936d0a952a3b65501
parent4adc5b2217c014ab5afc29705a93e968e127c247 (diff)
downloadjquery-80e3dfa6bac3340aafcc87e956e1c461ba570e68.tar.gz
jquery-80e3dfa6bac3340aafcc87e956e1c461ba570e68.zip
Core: Do not run window.onready when ready
Fixes #14802 (cherry picked from commit 2df1aad6a1c9376c2a477eba26ee992113ed1c23)
-rw-r--r--src/core/ready.js5
-rw-r--r--test/data/core/onready.html24
-rw-r--r--test/unit/core.js7
3 files changed, 34 insertions, 2 deletions
diff --git a/src/core/ready.js b/src/core/ready.js
index 3d0510e38..392c4849f 100644
--- a/src/core/ready.js
+++ b/src/core/ready.js
@@ -56,8 +56,9 @@ jQuery.extend({
readyList.resolveWith( document, [ jQuery ] );
// Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger("ready").off("ready");
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ jQuery( document ).off( "ready" );
}
}
});
diff --git a/test/data/core/onready.html b/test/data/core/onready.html
new file mode 100644
index 000000000..1e8f127e7
--- /dev/null
+++ b/test/data/core/onready.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+ <title>alias-masked DOM properties (#14074)</title>
+ <script>
+ var error = false;
+ window.onready = function() { error = "Called window.onready"; };
+ </script>
+ <script src="../../jquery.js"></script>
+</head>
+<body>
+ <form>
+ <input type="text" id="nodeName"/>
+ </form>
+ <script>
+ jQuery(function() {
+ setTimeout( function() {
+ window.parent.iframeCallback( error );
+ });
+ });
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/test/unit/core.js b/test/unit/core.js
index 02ad0f221..c59acb84c 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1492,3 +1492,10 @@ testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core
deepEqual( errors, [], "jQuery loaded" );
}
);
+
+testIframeWithCallback( "Don't call window.onready (#14802)", "core/onready.html",
+ function( error ) {
+ expect( 1 );
+ equal( error, false, "no call to user-defined onready" );
+ }
+);