]> source.dussan.org Git - jquery.git/commitdiff
Fix for bug #760 (fontSize returns different values in IE). This was part of a larger...
authorJohn Resig <jeresig@gmail.com>
Fri, 7 Sep 2007 21:39:44 +0000 (21:39 +0000)
committerJohn Resig <jeresig@gmail.com>
Fri, 7 Sep 2007 21:39:44 +0000 (21:39 +0000)
src/jquery/jquery.js

index d5a32e24da2431e0cf7d8a8efc3c8830562e25b2..537b4e2bec7a6b250e435ad4cf97ac827d45c3a6 100644 (file)
@@ -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;