| OLD | NEW |
| 1 Polymer({ | 1 Polymer({ |
| 2 | 2 |
| 3 is: 'iron-autogrow-textarea', | 3 is: 'iron-autogrow-textarea', |
| 4 | 4 |
| 5 behaviors: [ | 5 behaviors: [ |
| 6 Polymer.IronFormElementBehavior, | 6 Polymer.IronFormElementBehavior, |
| 7 Polymer.IronValidatableBehavior, | 7 Polymer.IronValidatableBehavior, |
| 8 Polymer.IronControlState | 8 Polymer.IronControlState |
| 9 ], | 9 ], |
| 10 | 10 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (this.hasValidator()) { | 143 if (this.hasValidator()) { |
| 144 valid = Polymer.IronValidatableBehavior.validate.call(this, this.value); | 144 valid = Polymer.IronValidatableBehavior.validate.call(this, this.value); |
| 145 } else { | 145 } else { |
| 146 valid = this.$.textarea.validity.valid; | 146 valid = this.$.textarea.validity.valid; |
| 147 this.invalid = !valid; | 147 this.invalid = !valid; |
| 148 } | 148 } |
| 149 this.fire('iron-input-validate'); | 149 this.fire('iron-input-validate'); |
| 150 return valid; | 150 return valid; |
| 151 }, | 151 }, |
| 152 | 152 |
| 153 _update: function() { | |
| 154 this.$.mirror.innerHTML = this._valueForMirror(); | |
| 155 | |
| 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; | |
| 161 } | |
| 162 }, | |
| 163 | |
| 164 _bindValueChanged: function() { | 153 _bindValueChanged: function() { |
| 165 var textarea = this.textarea; | 154 var textarea = this.textarea; |
| 166 if (!textarea) { | 155 if (!textarea) { |
| 167 return; | 156 return; |
| 168 } | 157 } |
| 169 | 158 |
| 170 textarea.value = this.bindValue; | 159 textarea.value = this.bindValue; |
| 171 this._update(); | 160 this.$.mirror.innerHTML = this._valueForMirror(); |
| 172 // manually notify because we don't want to notify until after setting val
ue | 161 // manually notify because we don't want to notify until after setting val
ue |
| 173 this.fire('bind-value-changed', {value: this.bindValue}); | 162 this.fire('bind-value-changed', {value: this.bindValue}); |
| 174 }, | 163 }, |
| 175 | 164 |
| 176 _onInput: function(event) { | 165 _onInput: function(event) { |
| 177 this.bindValue = event.path ? event.path[0].value : event.target.value; | 166 this.bindValue = event.path ? event.path[0].value : event.target.value; |
| 178 this._update(); | |
| 179 }, | 167 }, |
| 180 | 168 |
| 181 _constrain: function(tokens) { | 169 _constrain: function(tokens) { |
| 182 var _tokens; | 170 var _tokens; |
| 183 tokens = tokens || ['']; | 171 tokens = tokens || ['']; |
| 184 // Enforce the min and max heights for a multiline input to avoid measurem
ent | 172 // Enforce the min and max heights for a multiline input to avoid measurem
ent |
| 185 if (this.maxRows > 0 && tokens.length > this.maxRows) { | 173 if (this.maxRows > 0 && tokens.length > this.maxRows) { |
| 186 _tokens = tokens.slice(0, this.maxRows); | 174 _tokens = tokens.slice(0, this.maxRows); |
| 187 } else { | 175 } else { |
| 188 _tokens = tokens.slice(0); | 176 _tokens = tokens.slice(0); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 203 }, | 191 }, |
| 204 | 192 |
| 205 _updateCached: function() { | 193 _updateCached: function() { |
| 206 this.$.mirror.innerHTML = this._constrain(this.tokens); | 194 this.$.mirror.innerHTML = this._constrain(this.tokens); |
| 207 }, | 195 }, |
| 208 | 196 |
| 209 _computeValue: function() { | 197 _computeValue: function() { |
| 210 return this.bindValue; | 198 return this.bindValue; |
| 211 } | 199 } |
| 212 }); | 200 }); |
| OLD | NEW |