X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=e52e45330ee636ba2fac9b2ec6c9e6fdc4350692;hb=61e37d41490aed319a176c6ca7feb95e5505059c;hp=a16298d6c4f13d2da778c4595258344482f2b152;hpb=6071e939c7025ff7096673c93eaa7e2d78afbb6b;p=jquery.git diff --git a/src/css.js b/src/css.js index a16298d..e52e453 100644 --- a/src/css.js +++ b/src/css.js @@ -5,21 +5,25 @@ var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, rfloat = /float/i, rdashAlpha = /-([a-z])/ig, rupper = /([A-Z])/g, - rnumpx = /^\d+(?:px)?$/i, - rnum = /^\d/, + rnumpx = /^-?\d+(?:px)?$/i, + rnum = /^-?\d/, + + cssShow = { position: "absolute", visibility: "hidden", display:"block" }, + cssWidth = [ "Left", "Right" ], + cssHeight = [ "Top", "Bottom" ], // cache check for defaultView.getComputedStyle getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, // normalize float css property styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", - fcamelCase = function(all, letter){ + fcamelCase = function( all, letter ) { return letter.toUpperCase(); }; jQuery.fn.css = function( name, value ) { return access( this, name, value, true, function( elem, name, value ) { - if (value === undefined) { - return jQuery.css( elem, name ); + if ( value === undefined ) { + return jQuery.curCSS( elem, name ); } if ( typeof value === "number" && !rexclude.test(name) ) { @@ -78,12 +82,14 @@ jQuery.extend({ css: function( elem, name, force, extra ) { if ( name === "width" || name === "height" ) { - var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; + var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight; function getWH() { val = name === "width" ? elem.offsetWidth : elem.offsetHeight; - if ( extra === "border" ) { return; } + if ( extra === "border" ) { + return; + } jQuery.each( which, function() { if ( !extra ) { @@ -141,7 +147,13 @@ jQuery.extend({ name = name.replace( rupper, "-$1" ).toLowerCase(); - var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); + var defaultView = elem.ownerDocument.defaultView; + + if ( !defaultView ) { + return null; + } + + var computedStyle = defaultView.getComputedStyle( elem, null ); if ( computedStyle ) { ret = computedStyle.getPropertyValue( name );