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 _bindValueChanged: function() {
154 var textarea = this.textarea;
159 textarea.value = this.bindValue;
160 this.$.mirror.innerHTML = this._valueForMirror();
161 // manually notify because we don't want to notify until after setting value
162 this.fire('bind-value-changed', {value: this.bindValue});
165 _onInput: function(event) {
166 this.bindValue = event.path ? event.path[0].value : event.target.value;
169 _constrain: function(tokens) {
171 tokens = tokens || [''];
172 // Enforce the min and max heights for a multiline input to avoid measurement
173 if (this.maxRows > 0 && tokens.length > this.maxRows) {
174 _tokens = tokens.slice(0, this.maxRows);
176 _tokens = tokens.slice(0);
178 while (this.rows > 0 && _tokens.length < this.rows) {
181 return _tokens.join('<br>') + ' ';
184 _valueForMirror: function() {
185 var input = this.textarea;
189 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&').replace(/"/gm, '"').replace(/'/gm, ''').replace(/</gm, '<').replace(/>/gm, '>').split('\n') : [''];
190 return this._constrain(this.tokens);
193 _updateCached: function() {
194 this.$.mirror.innerHTML = this._constrain(this.tokens);
197 _computeValue: function() {
198 return this.bindValue;