From bff4a29310e93852ca1619dba9e26eefe11b0fb7 Mon Sep 17 00:00:00 2001 From: Reto Kaiser Date: Tue, 11 Nov 2014 16:32:51 +0100 Subject: [PATCH] Use "parseFloat" instead of "parseInt" for when sub-pixel css values are used --- jquery.autosize.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jquery.autosize.js b/jquery.autosize.js index 969b3df..07fde0b 100644 --- a/jquery.autosize.js +++ b/jquery.autosize.js @@ -84,7 +84,7 @@ } // IE8 and lower return 'auto', which parses to NaN, if no min-height is set. - minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height()); + minHeight = Math.max(parseFloat($ta.css('minHeight')) - boxOffset || 0, $ta.height()); $ta.css({ overflow: 'hidden', @@ -103,17 +103,17 @@ function setWidth() { var width; var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false; - + if (style) { width = ta.getBoundingClientRect().width; if (width === 0 || typeof width !== 'number') { - width = parseInt(style.width,10); + width = parseFloat(style.width); } $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){ - width -= parseInt(style[val],10); + width -= parseFloat(style[val]); }); } else { width = $ta.width(); @@ -128,7 +128,7 @@ mirrored = ta; mirror.className = options.className; mirror.id = options.id; - maxHeight = parseInt($ta.css('maxHeight'), 10); + maxHeight = parseFloat($ta.css('maxHeight')); // mirror is a duplicate textarea located off-screen that // is automatically updated to contain the same text as the @@ -138,7 +138,7 @@ $.each(typographyStyles, function(i,val){ styles[val] = $ta.css(val); }); - + $(mirror).css(styles).attr('wrap', $ta.attr('wrap')); setWidth(); @@ -166,8 +166,8 @@ } if (!ta.value && options.placeholder) { - // If the textarea is empty, copy the placeholder text into - // the mirror control and use that for sizing so that we + // If the textarea is empty, copy the placeholder text into + // the mirror control and use that for sizing so that we // don't end up with placeholder getting trimmed. mirror.value = ($ta.attr("placeholder") || ''); } else { @@ -176,7 +176,7 @@ mirror.value += options.append || ''; mirror.style.overflowY = ta.style.overflowY; - original = parseInt(ta.style.height,10); + original = parseFloat(ta.style.height); // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied mirror.scrollTop = 0;