]> 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:00:04 +0000 (21:00 -0500)
Fixes #14802

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

index e64977cd974fce7470674bbd3d7a2d51e4668a5d..122b1610d443d8446756c63dba8a59c07cac54bf 100644 (file)
@@ -51,8 +51,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 6801c7c0d22c8b174f853a698ebc70c8dfb2e13c..d1b221ce87f1f2deddb5103919c73d06f78a10e8 100644 (file)
@@ -1516,3 +1516,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" );
+       }
+);