3 is: 'iron-autogrow-textarea',
6 Polymer.IronFormElementBehavior,
7 Polymer.IronValidatableBehavior,
8 Polymer.IronControlState
14 * Use this property instead of `value` for two-way data binding.
17 observer: '_bindValueChanged',
22 * The initial number of rows.
31 observer: '_updateCached'
35 * The maximum number of rows this element can grow to until it
36 * scrolls. 0 means no maximum.
45 observer: '_updateCached'
49 * Bound to the textarea's `autocomplete` attribute.
57 * Bound to the textarea's `autofocus` attribute.
65 * Bound to the textarea's `inputmode` attribute.
72 * Bound to the textarea's `name` attribute.
79 * The value for this input, same as `bindValue`
84 computed: '_computeValue(bindValue)'
88 * Bound to the textarea's `placeholder` attribute.
95 * Bound to the textarea's `readonly` attribute.
102 * Set to true to mark the textarea as required.
109 * The maximum length of the input value.
122 * Returns the underlying textarea.
123 * @type HTMLTextAreaElement
126 return this.$.textarea;
130 * Returns true if `value` is valid. The validator provided in `validator`
131 * will be used first, if it exists; otherwise, the `textarea`'s validity
133 * @return {boolean} True if the value is valid.
135 validate: function() {
136 // Empty, non-required input is valid.
137 if (!this.required && this.value == '') {
138 this.invalid = false;
143 if (this.hasValidator()) {
144 valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
146 valid = this.$.textarea.validity.valid;
147 this.invalid = !valid;
149 this.fire('iron-input-validate');
153 _update: function() {
154 this.$.mirror.innerHTML = this._valueForMirror();
156 var textarea = this.textarea;
157 // If the value of the textarea was updated imperatively, then we
158 // need to manually update bindValue as well.
159 if (textarea && this.bindValue != textarea.value) {
160 this.bindValue = textarea.value;
164 _bindValueChanged: function() {
165 var textarea = this.textarea;
170 textarea.value = this.bindValue;
172 // manually notify because we don't want to notify until after setting value
173 this.fire('bind-value-changed', {value: this.bindValue});
176 _onInput: function(event) {
177 this.bindValue = event.path ? event.path[0].value : event.target.value;
181 _constrain: function(tokens) {
183 tokens = tokens || [''];
184 // Enforce the min and max heights for a multiline input to avoid measurement
185 if (this.maxRows > 0 && tokens.length > this.maxRows) {
186 _tokens = tokens.slice(0, this.maxRows);
188 _tokens = tokens.slice(0);
190 while (this.rows > 0 && _tokens.length < this.rows) {
193 return _tokens.join('<br>') + ' ';
196 _valueForMirror: function() {
197 var input = this.textarea;
201 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&').replace(/"/gm, '"').replace(/'/gm, ''').replace(/</gm, '<').replace(/>/gm, '>').split('\n') : [''];
202 return this._constrain(this.tokens);
205 _updateCached: function() {
206 this.$.mirror.innerHTML = this._constrain(this.tokens);
209 _computeValue: function() {
210 return this.bindValue;