Skip to content

Commit

Permalink
Merge pull request jackmoore#130 from jclement/master
Browse files Browse the repository at this point in the history
If textarea is empty, and placeholder text exists, use placeholder text for sizing.
  • Loading branch information
jackmoore committed Jan 11, 2014
2 parents f8daa27 + eaed0a9 commit c258937
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jquery.autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@
setWidth();
}

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);

Expand Down

0 comments on commit c258937

Please sign in to comment.