diff options
author | Jeff Clement <jeffrey.clement@gmail.com> | 2013-12-11 11:08:05 -0700 |
---|---|---|
committer | Jeff Clement <jeffrey.clement@gmail.com> | 2013-12-11 11:08:05 -0700 |
commit | eaed0a90235ff5ea50b83943cdc03152d6cb0146 (patch) | |
tree | 3d4ceeb6a05b5a93676283a46d47cc8dea453ca3 | |
parent | 9bd75719c13124641f2b791f0c9a1866aed17679 (diff) | |
download | autosize-eaed0a90235ff5ea50b83943cdc03152d6cb0146.zip autosize-eaed0a90235ff5ea50b83943cdc03152d6cb0146.tar.gz autosize-eaed0a90235ff5ea50b83943cdc03152d6cb0146.tar.bz2 |
fixed tabs/spaces and prevent issues if placeholder attribute is missing
-rw-r--r-- | jquery.autosize.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/jquery.autosize.js b/jquery.autosize.js index f410490..456f3ba 100644 --- a/jquery.autosize.js +++ b/jquery.autosize.js @@ -151,11 +151,15 @@ setWidth(); } - if (!ta.value) { - mirror.value = $(ta).attr("placeholder") + options.append; - } else { - mirror.value = ta.value + options.append; - } + if (!ta.value) { + // 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") || '') + options.append; + } else { + mirror.value = ta.value + options.append; + } + mirror.style.overflowY = ta.style.overflowY; original = parseInt(ta.style.height,10); |