aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-09-07 21:39:44 +0000
committerJohn Resig <jeresig@gmail.com>2007-09-07 21:39:44 +0000
commit3abf3125cb737f120b6b86c6011fd7ce0e6ba7cc (patch)
tree31e31e2da469fbfb6d368a7b74c976c4e740bf59
parentba2109136deda8fce5bd4d4dc96f0a45ffaf646a (diff)
downloadjquery-3abf3125cb737f120b6b86c6011fd7ce0e6ba7cc.tar.gz
jquery-3abf3125cb737f120b6b86c6011fd7ce0e6ba7cc.zip
Fix for bug #760 (fontSize returns different values in IE). This was part of a larger issue where IE returned non-pixel values from it's computed style - this normalizes it (thanks to a fix by Dean Edwards).
-rw-r--r--src/jquery/jquery.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index d5a32e24d..537b4e2be 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -643,6 +643,21 @@ jQuery.extend({
} else if (elem.currentStyle) {
var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) {
+ var style = elem.style.left;
+ var runtimeStyle = elem.runtimeStyle.left;
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ elem.style.left = ret || 0;
+ ret = elem.style.pixelLeft + "px";
+ elem.style.left = style;
+ elem.runtimeStyle.left = runtimeStyle;
+ }
}
return ret;