5 is: 'iron-autogrow-textarea',
8 Polymer.IronFormElementBehavior,
9 Polymer.IronValidatableBehavior,
10 Polymer.IronControlState
16 * Use this property instead of `value` for two-way data binding.
19 observer: '_bindValueChanged',
24 * The initial number of rows.
33 observer: '_updateCached'
37 * The maximum number of rows this element can grow to until it
38 * scrolls. 0 means no maximum.
47 observer: '_updateCached'
51 * Bound to the textarea's `autocomplete` attribute.
59 * Bound to the textarea's `autofocus` attribute.
67 * Bound to the textarea's `inputmode` attribute.
74 * Bound to the textarea's `name` attribute.
81 * The value for this input, same as `bindValue`
86 computed: '_computeValue(bindValue)'
90 * Bound to the textarea's `placeholder` attribute.
97 * Bound to the textarea's `readonly` attribute.
104 * Set to true to mark the textarea as required.
111 * The maximum length of the input value.
124 * Returns the underlying textarea.
125 * @type HTMLTextAreaElement
128 return this.$.textarea;
132 * Returns true if `value` is valid. The validator provided in `validator`
133 * will be used first, if it exists; otherwise, the `textarea`'s validity
135 * @return {boolean} True if the value is valid.
137 validate: function() {
138 // Empty, non-required input is valid.
139 if (!this.required && this.value == '') {
140 this.invalid = false;
145 if (this.hasValidator()) {
146 valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
148 valid = this.$.textarea.validity.valid;
149 this.invalid = !valid;
151 this.fire('iron-input-validate');
155 _update: function() {
156 this.$.mirror.innerHTML = this._valueForMirror();
158 var textarea = this.textarea;
159 // If the value of the textarea was updated imperatively, then we
160 // need to manually update bindValue as well.
161 if (textarea && this.bindValue != textarea.value) {
162 this.bindValue = textarea.value;
166 _bindValueChanged: function() {
167 var textarea = this.textarea;
172 textarea.value = this.bindValue;
174 // manually notify because we don't want to notify until after setting value
175 this.fire('bind-value-changed', {value: this.bindValue});
178 _onInput: function(event) {
179 this.bindValue = event.path ? event.path[0].value : event.target.value;
183 _constrain: function(tokens) {
185 tokens = tokens || [''];
186 // Enforce the min and max heights for a multiline input to avoid measurement
187 if (this.maxRows > 0 && tokens.length > this.maxRows) {
188 _tokens = tokens.slice(0, this.maxRows);
190 _tokens = tokens.slice(0);
192 while (this.rows > 0 && _tokens.length < this.rows) {
195 return _tokens.join('<br>') + ' ';
198 _valueForMirror: function() {
199 var input = this.textarea;
203 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&').replace(/"/gm, '"').replace(/'/gm, ''').replace(/</gm, '<').replace(/>/gm, '>').split('\n') : [''];
204 return this._constrain(this.tokens);
207 _updateCached: function() {
208 this.$.mirror.innerHTML = this._constrain(this.tokens);
211 _computeValue: function() {
212 return this.bindValue;