From 9b04201ff21b6e5932dc21679774f398d6940cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski?= Date: Tue, 28 Jul 2015 12:23:28 +0200 Subject: [PATCH] Core:CSS: Attach test nodes to documentElement, not body 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 | 5 ----- src/css/addGetHookIf.js | 16 +++------------- src/css/support.js | 11 +++-------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/core/ready.js b/src/core/ready.js index 70e9574cc..ae72fdeab 100644 --- a/src/core/ready.js +++ b/src/core/ready.js @@ -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; diff --git a/src/css/addGetHookIf.js b/src/css/addGetHookIf.js index 7efcbc860..e12f3598d 100644 --- a/src/css/addGetHookIf.js +++ b/src/css/addGetHookIf.js @@ -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 ); } }; diff --git a/src/css/support.js b/src/css/support.js index 854fa6b36..6b5731771 100644 --- a/src/css/support.js +++ b/src/css/support.js @@ -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 ); } })();