Permalink
Browse files

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
  • Loading branch information...
mgol committed Jul 28, 2015
1 parent 3923bb8 commit 9b04201ff21b6e5932dc21679774f398d6940cfa
Showing with 6 additions and 26 deletions.
  1. +0 −5 src/core/ready.js
  2. +3 −13 src/css/addGetHookIf.js
  3. +3 −8 src/css/support.js
View
@@ -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;
View
@@ -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 );
}
};
View
@@ -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 );
}
})();

0 comments on commit 9b04201

Please sign in to comment.