cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
rposition = /^(top|right|bottom|left)$/,
- eventsToggle = jQuery.fn.toggle;
+ eventsToggle = jQuery.fn.toggle,
+
+ cssNormalTransform = {
+ letterSpacing: 0,
+ fontWeight: 400,
+ lineHeight: 1
+ };
// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) {
val = curCSS( elem, name );
}
+ //convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
// Return, converting to number if forced or a qualifier was provided and val looks numeric
- if ( numeric || extra ) {
+ if ( numeric || extra !== undefined ) {
num = parseFloat( val );
return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
}
Tween.propHooks = {
_default: {
get: function( tween ) {
- var parsed, result;
+ var result;
if ( tween.elem[ tween.prop ] != null &&
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
return tween.elem[ tween.prop ];
}
- result = jQuery.css( tween.elem, tween.prop );
- // Empty strings, null, undefined and "auto" are converted to 0,
- // complex values such as "rotate(1rad)" are returned as is,
- // simple values such as "10px" are parsed to Float.
- return isNaN( parsed = parseFloat( result ) ) ?
- !result || result === "auto" ? 0 : result : parsed;
+ // passing any value as a 4th paramter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, false, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
},
set: function( tween ) {
// use step hook for back compat - use cssHook if its there - use .style if its
equal( el_dis.css("height"), el_dis.css("height", el_dis.css("height")).css("height"), "css('height') is not respecting box-sizing for disconnected element, see #11004");
});
+test("certain css values of 'normal' should be convertable to a number, see #8627", function() {
+ var el = jQuery("<div style='letter-spacing:normal;font-weight:normal;line-height:normal;'>test</div>").appendTo("#qunit-fixture");
+
+ ok( jQuery.isNumeric( parseFloat( el.css("letterSpacing") ) ), "css('letterSpacing') not convertable to number, see #8627" );
+ ok( jQuery.isNumeric( parseFloat( el.css("fontWeight") ) ), "css('fontWeight') not convertable to number, see #8627" );
+ ok( jQuery.isNumeric( parseFloat( el.css("lineHeight") ) ), "css('lineHeight') not convertable to number, see #8627" );
+});
+
test( "cssHooks - expand", function() {
expect( 15 );
var result,