Skip to content

Commit

Permalink
Fixed boxModel support - is now computed with feature detection, rath…
Browse files Browse the repository at this point in the history
…er than sniffing.
  • Loading branch information
jeresig committed Jan 11, 2009
1 parent 0066ba3 commit 7346a47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -10,9 +10,9 @@ PLUG_DIR = ../plugins

BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/data.js\
${SRC_DIR}/support.js\
${SRC_DIR}/selector.js\
${SRC_DIR}/event.js\
${SRC_DIR}/support.js\
${SRC_DIR}/ajax.js\
${SRC_DIR}/fx.js\
${SRC_DIR}/offset.js\
Expand Down
3 changes: 0 additions & 3 deletions src/core.js
Expand Up @@ -1146,9 +1146,6 @@ jQuery.browser = {
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

// Check to see if the W3C box model is being used
jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";

jQuery.each({
parent: function(elem){return elem.parentNode;},
parents: function(elem){return jQuery.dir(elem,"parentNode");},
Expand Down
14 changes: 13 additions & 1 deletion src/support.js
Expand Up @@ -53,7 +53,8 @@

// Will be defined later
scriptEval: false,
noCloneEvent: true
noCloneEvent: true,
boxModel: null
};

script.type = "text/javascript";
Expand Down Expand Up @@ -83,6 +84,17 @@
div.cloneNode(true).fireEvent("onclick");
}

// Figure out if the W3C box model works as expected
// document.body must exist before we can do this
jQuery(function(){
var div = document.createElement("div");
div.style.width = "1px";
div.style.paddingLeft = "1px";

document.body.appendChild( div );
jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
document.body.removeChild( div );
});
})();

var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
Expand Down

0 comments on commit 7346a47

Please sign in to comment.