Skip to content

Commit 9b04201

Browse files
committed
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
1 parent 3923bb8 commit 9b04201

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

src/core/ready.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ jQuery.extend({
3838
return;
3939
}
4040

41-
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
42-
if ( !document.body ) {
43-
return setTimeout( jQuery.ready );
44-
}
45-
4641
// Remember that the DOM is ready
4742
jQuery.isReady = true;
4843

src/css/addGetHookIf.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,14 @@ function addGetHookIf( conditionFn, hookFn ) {
44
// Define the hook, we'll check on the first run if it's really needed.
55
return {
66
get: function() {
7-
var condition = conditionFn();
8-
9-
if ( condition == null ) {
10-
// The test was not ready at this point; screw the hook this time
11-
// but check again when needed next time.
12-
return;
13-
}
14-
15-
if ( condition ) {
16-
// Hook not needed (or it's not possible to use it due to missing dependency),
17-
// remove it.
18-
// Since there are no other hooks for marginRight, remove the whole object.
7+
if ( conditionFn() ) {
8+
// Hook not needed (or it's not possible to use it due
9+
// to missing dependency), remove it.
1910
delete this.get;
2011
return;
2112
}
2213

2314
// Hook needed; redefine it so that the support test is not executed again.
24-
2515
return (this.get = hookFn).apply( this, arguments );
2616
}
2717
};

src/css/support.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,10 @@ define([
8888

8989
function computeStyleTests() {
9090
var contents, divStyle,
91-
body = document.body;
92-
93-
if ( !body || !body.style ) {
94-
// Test fired too early or in an unsupported environment, exit.
95-
return;
96-
}
91+
documentElement = document.documentElement;
9792

9893
// Setup
99-
body.appendChild( container );
94+
documentElement.appendChild( container );
10095

10196
div.style.cssText =
10297
// Support: Android 2.3
@@ -162,7 +157,7 @@ define([
162157
}
163158

164159
// Teardown
165-
body.removeChild( container );
160+
documentElement.removeChild( container );
166161
}
167162

168163
})();

0 commit comments

Comments
 (0)