Skip to content

Commit 449e099

Browse files
committed
Landing tweak from 'haruka' that fixes non-pixel fontSize values in IE. Fixes #760.
1 parent bf71575 commit 449e099

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ jQuery.extend({
167167

168168
// Put in the new values to get a computed value out
169169
elem.runtimeStyle.left = elem.currentStyle.left;
170-
style.left = ret || 0;
170+
style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
171171
ret = style.pixelLeft + "px";
172172

173173
// Revert the changed values
@@ -212,4 +212,4 @@ if ( jQuery.expr && jQuery.expr.filters ) {
212212
jQuery.expr.filters.visible = function(elem){
213213
return !jQuery.expr.filters.hidden(elem);
214214
};
215-
}
215+
}

test/data/testsuite.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ div.chain.out { background: green; }
103103
div.chain.out div { background: red; display: none; }
104104

105105
div#show-tests * { display: none; }
106+
107+
#nothiddendiv { font-size: 16px; }
108+
#nothiddendivchild.em { font-size: 2em; }
109+
#nothiddendivchild.prct { font-size: 150%; }

test/unit/css.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module("css");
22

33
test("css(String|Hash)", function() {
4-
expect(23);
4+
expect(27);
55

66
equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
77

@@ -38,6 +38,17 @@ test("css(String|Hash)", function() {
3838
equals( jQuery('#empty').css('opacity'), '0', "Assert opacity is accessible via filter property set in stylesheet in IE" );
3939
jQuery('#empty').css({ opacity: '1' });
4040
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." );
4152
});
4253

4354
test("css(String, Object)", function() {

0 commit comments

Comments
 (0)