Skip to content

Commit

Permalink
Landing pull request 509. Add a comment explaining the use of documen…
Browse files Browse the repository at this point in the history
…t.getElementsByTagName('body')[0] instead of document.body.

More Details:
 - jquery#509
  • Loading branch information
mathiasbynens authored and timmywil committed Sep 20, 2011
1 parent b03648c commit 26898f0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/support.js
Expand Up @@ -122,7 +122,7 @@ jQuery.support = (function() {
div.cloneNode( true ).fireEvent( "onclick" );
}

// Check if a radio maintains it's value
// Check if a radio maintains its value
// after being appended to the DOM
input = document.createElement("input");
input.value = "t";
Expand All @@ -142,7 +142,11 @@ jQuery.support = (function() {
// Figure out if the W3C box model works as expected
div.style.width = div.style.paddingLeft = "1px";

body = document.getElementsByTagName( "body" )[ 0 ];
// We don't want to do body-related feature tests on frameset
// documents, which lack a body. So we use
// document.getElementsByTagName("body")[0], which is undefined in
// frameset documents, while document.body isn’t. (7398)
body = document.getElementsByTagName("body")[ 0 ];
// We use our own, invisible, body unless the body is already present
// in which case we use a div (#9239)
testElement = document.createElement( body ? "div" : "body" );
Expand All @@ -157,8 +161,8 @@ jQuery.support = (function() {
if ( body ) {
jQuery.extend( testElementStyle, {
position: "absolute",
left: "-1000px",
top: "-1000px"
left: "-999px",
top: "-999px"
});
}
for ( i in testElementStyle ) {
Expand Down

0 comments on commit 26898f0

Please sign in to comment.