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
This commit is contained in:
Michał Gołębiowski 2015-07-28 12:23:28 +02:00
parent 3923bb8400
commit 9b04201ff2
3 changed files with 6 additions and 26 deletions

View 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;

View 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 );
}
};

View 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 );
}
})();