]> source.dussan.org Git - jquery.git/commitdiff
Core:CSS: Attach test nodes to documentElement, not body
authorMichał Gołębiowski <m.goleb@gmail.com>
Tue, 28 Jul 2015 10:23:28 +0000 (12:23 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Sun, 16 Aug 2015 20:28:35 +0000 (22:28 +0200)
Attaching test divs to document.documentElement instead of document.body
used to cause issues in jQuery 1.x; jQuery Compat doesn't execute any tests
on document ready, though so it could be aligned with master.

This makes jQuery Compat support tests work correctly even if jQuery is
included & used in head before body even exists - making it similar to
the master behavior.

Fixes gh-2502

src/core/ready.js
src/css/addGetHookIf.js
src/css/support.js

index 70e9574cc70831f6b223f5df5d1bb41a121e38b3..ae72fdeaba242a9d9bbc9bc54ed548334c0b8ad2 100644 (file)
@@ -38,11 +38,6 @@ jQuery.extend({
                        return;
                }
 
-               // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
-               if ( !document.body ) {
-                       return setTimeout( jQuery.ready );
-               }
-
                // Remember that the DOM is ready
                jQuery.isReady = true;
 
index 7efcbc860eaec46cf3295cbc7422a16d9cecf79c..e12f3598d366e7d2f5d95f553adb0db329f9eac4 100644 (file)
@@ -4,24 +4,14 @@ function addGetHookIf( conditionFn, hookFn ) {
        // Define the hook, we'll check on the first run if it's really needed.
        return {
                get: function() {
-                       var condition = conditionFn();
-
-                       if ( condition == null ) {
-                               // The test was not ready at this point; screw the hook this time
-                               // but check again when needed next time.
-                               return;
-                       }
-
-                       if ( condition ) {
-                               // Hook not needed (or it's not possible to use it due to missing dependency),
-                               // remove it.
-                               // Since there are no other hooks for marginRight, remove the whole object.
+                       if ( conditionFn() ) {
+                               // Hook not needed (or it's not possible to use it due
+                               // to missing dependency), remove it.
                                delete this.get;
                                return;
                        }
 
                        // Hook needed; redefine it so that the support test is not executed again.
-
                        return (this.get = hookFn).apply( this, arguments );
                }
        };
index 854fa6b3603e3e2cfc9a792d83754175151fd40a..6b57317713ed21d7498bd296e47aaed889a9aac1 100644 (file)
@@ -88,15 +88,10 @@ define([
 
        function computeStyleTests() {
                var contents, divStyle,
-                       body = document.body;
-
-               if ( !body || !body.style ) {
-                       // Test fired too early or in an unsupported environment, exit.
-                       return;
-               }
+                       documentElement = document.documentElement;
 
                // Setup
-               body.appendChild( container );
+               documentElement.appendChild( container );
 
                div.style.cssText =
                        // Support: Android 2.3
@@ -162,7 +157,7 @@ define([
                }
 
                // Teardown
-               body.removeChild( container );
+               documentElement.removeChild( container );
        }
 
 })();