Added a fix for the Safari computedStyle bug.

This commit is contained in:
John Resig 2006-08-25 21:22:21 +00:00
parent 906478800d
commit 94fc6aac19

36
src/jquery/jquery.js vendored
View file

@ -949,21 +949,35 @@ jQuery.extend({
return jQuery.curCSS( e, p ); return jQuery.curCSS( e, p );
}, },
curCSS: function(e,p,force) { curCSS: function(elem, prop, force) {
var r; 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];
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];
} else if (document.defaultView && document.defaultView.getComputedStyle) { } else if (document.defaultView && document.defaultView.getComputedStyle) {
p = p.replace(/([A-Z])/g,"-$1").toLowerCase();
var s = document.defaultView.getComputedStyle(e,""); prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
r = s ? s.getPropertyValue(p) : null; 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) { clean: function(a) {