X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=53d5f4a4b1601bd0c4e83a00051d659beb0aaf05;hb=3e3b86c7a7437c7b0416a2ac8385cf9403fc9e28;hp=39ffdb58084fe1717bed933326ac83d4619b0832;hpb=f97f77c034dc62001a687c728bdfdc71a23bf6b8;p=jquery.git diff --git a/src/core.js b/src/core.js index 39ffdb5..53d5f4a 100644 --- a/src/core.js +++ b/src/core.js @@ -290,7 +290,7 @@ jQuery.fn = jQuery.prototype = { clone: function( events ) { // Do the clone var ret = this.map(function(){ - if ( jQuery.browser.msie ) { + if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { // IE copies events bound via attachEvent when // using cloneNode. Calling detachEvent on the // clone will also remove the events from the orignal @@ -494,16 +494,9 @@ jQuery.fn = jQuery.prototype = { this.cloneNode( true ) : this; + // execute all scripts after the elements have been injected if ( jQuery.nodeName( elem, "script" ) ) { - - // If scripts are waiting to be executed, wait on this script as well - if ( scripts.length ) - scripts = scripts.add( elem ); - - // If nothing is waiting to be executed, run immediately - else - evalScript( 0, elem ); - + scripts = scripts.add( elem ); } else { // Remove any inner scripts for later evaluation if ( elem.nodeType == 1 ) @@ -779,55 +772,22 @@ jQuery.extend({ }, css: function( elem, name, force ) { - if ( name == "height" || name == "width" ) { - var old = {}, height, width; - - // Revert the padding and border widths to get the - // correct height/width values - jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){ - old[ "padding" + this ] = 0; - old[ "border" + this + "Width" ] = 0; - }); - - // Swap out the padding/border values temporarily - jQuery.swap( elem, old, function() { - - // If the element is visible, then the calculation is easy - if ( jQuery( elem ).is(":visible") ) { - height = elem.offsetHeight; - width = elem.offsetWidth; - - // Otherwise, we need to flip out more values - } else { - elem = jQuery( elem.cloneNode(true) ) - .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end() - .css({ - visibility: "hidden", - position: "absolute", - display: "block", - right: "0", - left: "0" - }).appendTo( elem.parentNode )[0]; - - var position = jQuery.css( elem.parentNode, "position" ) || "static"; - if ( position == "static" ) - elem.parentNode.style.position = "relative"; - - height = elem.clientHeight; - width = elem.clientWidth; - - if ( position == "static" ) - elem.parentNode.style.position = "static"; - - elem.parentNode.removeChild( elem ); - } - }); + if ( name == "width" || name == "height" ) { + var width, height, props = { position: "absolute", visibility: "hidden", display:"block" }; + + function getWH() { + width = elem.clientWidth; + height = elem.clientHeight; + } + + if ( jQuery(elem).is(":visible") ) + getWH(); + else + jQuery.swap( elem, props, getWH ); - return name == "height" ? - height : - width; + return name == "width" ? width : height; } - + return jQuery.curCSS( elem, name, force ); }, @@ -1351,8 +1311,11 @@ jQuery.each([ "Height", "Width" ], function(i, name){ // Get document width or height this[0] == document ? - // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth) - Math.max( document.body[ "scroll" + name ], document.body[ "offset" + name ] ) : + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater + Math.max( + Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]), + Math.max(document.body["offset" + name], document.documentElement["offset" + name]) + ) : // Get or set width or height on the element size == undefined ?