]> source.dussan.org Git - jquery.git/commitdiff
Core: Do not run window.onready when ready
authorDave Methvin <dave.methvin@gmail.com>
Tue, 4 Mar 2014 03:04:23 +0000 (22:04 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 5 Mar 2014 02:50:43 +0000 (21:50 -0500)
Fixes #14802
(cherry picked from commit 2df1aad6a1c9376c2a477eba26ee992113ed1c23)

src/core/ready.js
test/data/core/onready.html [new file with mode: 0644]
test/unit/core.js

index 3d0510e38ad625228779ad4c4007b110cf7041de..392c4849f99df6d5ae3814a3a21395f76f6b97d3 100644 (file)
@@ -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 (file)
index 0000000..1e8f127
--- /dev/null
@@ -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
index 02ad0f221639f2309197558f04344395584fb988..c59acb84cd554945e62a5d8028d78810f7b00516 100644 (file)
@@ -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" );
+       }
+);