+
+ // Get the width of the input with the placeholder text as
+ // the value and save it so that we don't keep recalculating
+ if (
+ this.contentWidthWithPlaceholder === undefined &&
+ this.$input.val() === '' &&
+ this.$input.attr( 'placeholder' ) !== undefined
+ ) {
+ this.$input.val( this.$input.attr( 'placeholder' ) );
+ this.contentWidthWithPlaceholder = this.$input[ 0 ].scrollWidth;
+ this.$input.val( '' );
+
+ }
+
+ // Always keep the input wide enough for the placeholder text
+ contentWidth = Math.max(
+ this.$input[ 0 ].scrollWidth,
+ // undefined arguments in Math.max lead to NaN
+ ( this.contentWidthWithPlaceholder === undefined ) ?
+ 0 : this.contentWidthWithPlaceholder
+ );