Skip to content

Commit

Permalink
Fixes #9109. When jQuery is loaded in the body, then the fake body el…
Browse files Browse the repository at this point in the history
…ement used in support has to be inserted before the document's body for boxModel to be properly detected (got the hint by looking at the code in jQuery mobile). Test page added so that we can keep checking this.
  • Loading branch information
jaubourg committed May 9, 2011
1 parent 18b1cf2 commit efd0fce
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
jQuery.support = (function() {

var div = document.createElement( "div" ),
documentElement = document.documentElement,
all,
a,
select,
Expand Down Expand Up @@ -150,7 +151,7 @@ jQuery.support = (function() {
body.style[ i ] = bodyStyle[ i ];
}
body.appendChild( div );
document.documentElement.appendChild( body );
documentElement.insertBefore( body, documentElement.firstChild );

// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
Expand Down Expand Up @@ -210,7 +211,7 @@ jQuery.support = (function() {

// Remove the body element we added
body.innerHTML = "";
document.documentElement.removeChild( body );
documentElement.removeChild( body );

// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
Expand Down
33 changes: 33 additions & 0 deletions test/boxModelIE.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h3>jQuery Test boxModel detection in IE 6 & 7 compatMode="CSS1Compat"</h3>
<div>document.compatMode = <span id="compat-mode">?</span></div>
<div>jQuery.support.boxModel = <span id="box-model">?</span></div>
<script src="../src/core.js"></script>
<script src="../src/deferred.js"></script>
<script src="../src/support.js"></script>
<script src="../src/data.js"></script>
<script src="../src/queue.js"></script>
<script src="../src/attributes.js"></script>
<script src="../src/event.js"></script>
<script src="../src/sizzle/sizzle.js"></script>
<script src="../src/sizzle-jquery.js"></script>
<script src="../src/traversing.js"></script>
<script src="../src/manipulation.js"></script>
<script src="../src/css.js"></script>
<script src="../src/ajax.js"></script>
<script src="../src/ajax/jsonp.js"></script>
<script src="../src/ajax/script.js"></script>
<script src="../src/ajax/xhr.js"></script>
<script src="../src/effects.js"></script>
<script src="../src/offset.js"></script>
<script src="../src/dimensions.js"></script>
<script>
jQuery(function() {
jQuery( "#compat-mode" ).text( document.compatMode );
jQuery( "#box-model" ).text( jQuery.support.boxModel );
});
</script>
</body>
</html>

0 comments on commit efd0fce

Please sign in to comment.