There is a ticket with JQuery,Ticket #5032, which describes a problem
where JQuery fails during start-up with the message "document.body is
null or not an object". So far the bug is only reproducable in IE6. It
seems that a fix is not imminent for this issue, so I may need to
patch JQuery.

I am curious to know what the implications of wrapping the place in
code where the error is thrown from.

The error originates from support.js

82          // Figure out if the W3C box model works as expected
83          // document.body must exist before we can do this
84          jQuery(function(){
85              var div = document.createElement("div");
86              div.style.width = div.style.paddingLeft = "1px";
87
88              document.body.appendChild( div );
89              jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth
=== 2;
90              document.body.removeChild( div ).style.display = 'none';
91              div = null;
92          });

would change to:

82          // Figure out if the W3C box model works as expected
83          // document.body must exist before we can do this
84          jQuery(function(){
                if (document.body != null){
85                   var div = document.createElement("div");
86                   div.style.width = div.style.paddingLeft = "1px";
87
88                   document.body.appendChild( div );
89                   jQuery.boxModel = jQuery.support.boxModel =
div.offsetWidth === 2;
90                  document.body.removeChild( div ).style.display =
'none';
91                  div = null;
                }
92          });


As I understand, this method is performing a W3C box model support
test to determine if the browser renders the div in conformance with
W3C standards.  This is done when the library is first loaded.

I am hoping someone can answer the following:

1.    If the attribute jQuery.boxModel is never referenced anywhere in
my code; can this break internal jQuery functionality at all?


2.    Would it be better to simply comment this code altogether and
simply default jQuery.boxModel to false?


3.    Is there any other code executed at start-up that I should be
concerned about?  (ie. anywhere else where a DOM test like this is
executed?

Reply via email to