From: John Resig <jeresig@gmail.com>
Date: Fri, 25 Aug 2006 21:22:21 +0000 (+0000)
Subject: Added a fix for the Safari computedStyle bug.
X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=94fc6aac1990dc3233c70f471432c5b9f230e756;p=jquery.git

Added a fix for the Safari computedStyle bug.
---

diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 017d9ad..33d7c05 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -949,21 +949,35 @@ jQuery.extend({
 		return jQuery.curCSS( e, p );
 	},
 
-	curCSS: function(e,p,force) {
-		var r;
-	
-		if (!force && e.style[p])
-			r = e.style[p];
-		else if (e.currentStyle) {
-			var np = p.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
-			r = e.currentStyle[p] || e.currentStyle[np];
+	curCSS: function(elem, prop, force) {
+		var ret;
+	
+		if (!force && elem.style[prop]) {
+
+			ret = elem.style[prop];
+
+		} else if (elem.currentStyle) {
+
+			var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
+			ret = elem.currentStyle[prop] || elem.currentStyle[np];
+
 		} else if (document.defaultView && document.defaultView.getComputedStyle) {
-			p = p.replace(/([A-Z])/g,"-$1").toLowerCase();
-			var s = document.defaultView.getComputedStyle(e,"");
-			r = s ? s.getPropertyValue(p) : null;
+
+			prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
+			var cur = document.defaultView.getComputedStyle(elem, null);
+
+			if ( cur )
+				ret = cur.getPropertyValue(prop);
+			else if ( prop == 'display' )
+				ret = 'none';
+			else
+				jQuery.swap(elem, { display: 'block' }, function() {
+					ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
+				});
+
 		}
 		
-		return r;
+		return ret;
 	},
 	
 	clean: function(a) {