Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Landing tweak from 'haruka' that fixes non-pixel fontSize values in I…

…E. Fixes #760.
  • Loading branch information...
commit 449e099b97d823ed0252d8821880bc0e471701ea 1 parent bf71575
John Resig authored November 11, 2009
4  src/css.js
@@ -167,7 +167,7 @@ jQuery.extend({
167 167
 
168 168
 				// Put in the new values to get a computed value out
169 169
 				elem.runtimeStyle.left = elem.currentStyle.left;
170  
-				style.left = ret || 0;
  170
+				style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
171 171
 				ret = style.pixelLeft + "px";
172 172
 
173 173
 				// Revert the changed values
@@ -212,4 +212,4 @@ if ( jQuery.expr && jQuery.expr.filters ) {
212 212
 	jQuery.expr.filters.visible = function(elem){
213 213
 		return !jQuery.expr.filters.hidden(elem);
214 214
 	};
215  
-}
  215
+}
4  test/data/testsuite.css
@@ -103,3 +103,7 @@ div.chain.out { background: green; }
103 103
 div.chain.out div { background: red; display: none; }
104 104
 
105 105
 div#show-tests * { display: none; }
  106
+
  107
+#nothiddendiv { font-size: 16px; }
  108
+#nothiddendivchild.em { font-size: 2em; }
  109
+#nothiddendivchild.prct { font-size: 150%; }
13  test/unit/css.js
... ...
@@ -1,7 +1,7 @@
1 1
 module("css");
2 2
 
3 3
 test("css(String|Hash)", function() {
4  
-	expect(23);
  4
+	expect(27);
5 5
 
6 6
 	equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
7 7
 
@@ -38,6 +38,17 @@ test("css(String|Hash)", function() {
38 38
 	equals( jQuery('#empty').css('opacity'), '0', "Assert opacity is accessible via filter property set in stylesheet in IE" );
39 39
 	jQuery('#empty').css({ opacity: '1' });
40 40
 	equals( jQuery('#empty').css('opacity'), '1', "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
  41
+
  42
+	var div = jQuery('#nothiddendiv'), child = jQuery('#nothiddendivchild');
  43
+
  44
+	equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." );
  45
+	equals( parseInt(child.css("fontSize")), 16, "Verify fontSize px set." );
  46
+
  47
+	child.attr("class", "em");
  48
+	equals( parseInt(child.css("fontSize")), 32, "Verify fontSize em set." );
  49
+
  50
+	child.attr("class", "prct");
  51
+	equals( parseInt(child.css("fontSize")), 24, "Verify fontSize % set." );
41 52
 });
42 53
 
43 54
 test("css(String, Object)", function() {

0 notes on commit 449e099

Please sign in to comment.
Something went wrong with that request. Please try again.