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 _bindValueChanged: function() {
156 var textarea = this.textarea;
161 textarea.value = this.bindValue;
162 this.$.mirror.innerHTML = this._valueForMirror();
163 // manually notify because we don't want to notify until after setting value
164 this.fire('bind-value-changed', {value: this.bindValue});
167 _onInput: function(event) {
168 this.bindValue = event.path ? event.path[0].value : event.target.value;
171 _constrain: function(tokens) {
173 tokens = tokens || [''];
174 // Enforce the min and max heights for a multiline input to avoid measurement
175 if (this.maxRows > 0 && tokens.length > this.maxRows) {
176 _tokens = tokens.slice(0, this.maxRows);
178 _tokens = tokens.slice(0);
180 while (this.rows > 0 && _tokens.length < this.rows) {
183 return _tokens.join('<br>') + ' ';
186 _valueForMirror: function() {
187 var input = this.textarea;
191 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&').replace(/"/gm, '"').replace(/'/gm, ''').replace(/</gm, '<').replace(/>/gm, '>').split('\n') : [''];
192 return this._constrain(this.tokens);
195 _updateCached: function() {
196 this.$.mirror.innerHTML = this._constrain(this.tokens);
199 _computeValue: function() {
200 return this.bindValue;