Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js

Issue 1766433002: Roll Polymer to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 properties: { 11 properties: {
12 12
13 /** 13 /**
14 * Use this property instead of `value` for two-way data binding. 14 * Use this property instead of `value` for two-way data binding.
15 * 15 * This property will be deprecated in the future. Use `value` instead.
16 * @type {string|number|undefined|null} 16 * @type {string|number}
17 */ 17 */
18 bindValue: { 18 bindValue: {
19 observer: '_bindValueChanged', 19 observer: '_bindValueChanged',
20 type: String 20 type: String
21 }, 21 },
22 22
23 /** 23 /**
24 * The initial number of rows. 24 * The initial number of rows.
25 * 25 *
26 * @attribute rows 26 * @attribute rows
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }, 64 },
65 65
66 /** 66 /**
67 * Bound to the textarea's `inputmode` attribute. 67 * Bound to the textarea's `inputmode` attribute.
68 */ 68 */
69 inputmode: { 69 inputmode: {
70 type: String 70 type: String
71 }, 71 },
72 72
73 /** 73 /**
74 * Bound to the textarea's `name` attribute.
75 */
76 name: {
77 type: String
78 },
79
80 /**
81 * The value for this input, same as `bindValue`
82 */
83 value: {
84 notify: true,
85 type: String,
86 computed: '_computeValue(bindValue)'
87 },
88
89 /**
90 * Bound to the textarea's `placeholder` attribute. 74 * Bound to the textarea's `placeholder` attribute.
91 */ 75 */
92 placeholder: { 76 placeholder: {
93 type: String 77 type: String
94 }, 78 },
95 79
96 /** 80 /**
97 * Bound to the textarea's `readonly` attribute. 81 * Bound to the textarea's `readonly` attribute.
98 */ 82 */
99 readonly: { 83 readonly: {
(...skipping 13 matching lines...) Expand all
113 maxlength: { 97 maxlength: {
114 type: Number 98 type: Number
115 } 99 }
116 100
117 }, 101 },
118 102
119 listeners: { 103 listeners: {
120 'input': '_onInput' 104 'input': '_onInput'
121 }, 105 },
122 106
107 observers: [
108 '_onValueChanged(value)'
109 ],
110
123 /** 111 /**
124 * Returns the underlying textarea. 112 * Returns the underlying textarea.
125 * @type HTMLTextAreaElement 113 * @type HTMLTextAreaElement
126 */ 114 */
127 get textarea() { 115 get textarea() {
128 return this.$.textarea; 116 return this.$.textarea;
129 }, 117 },
130 118
131 /** 119 /**
132 * Returns textarea's selection start. 120 * Returns textarea's selection start.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 177 }
190 178
191 // If the bindValue changed manually, then we need to also update 179 // If the bindValue changed manually, then we need to also update
192 // the underlying textarea's value. Otherwise this change was probably 180 // the underlying textarea's value. Otherwise this change was probably
193 // generated from the _onInput handler, and the two values are already 181 // generated from the _onInput handler, and the two values are already
194 // the same. 182 // the same.
195 if (textarea.value !== this.bindValue) { 183 if (textarea.value !== this.bindValue) {
196 textarea.value = !(this.bindValue || this.bindValue === 0) ? '' : this.b indValue; 184 textarea.value = !(this.bindValue || this.bindValue === 0) ? '' : this.b indValue;
197 } 185 }
198 186
187 this.value = this.bindValue;
199 this.$.mirror.innerHTML = this._valueForMirror(); 188 this.$.mirror.innerHTML = this._valueForMirror();
200 // manually notify because we don't want to notify until after setting val ue 189 // manually notify because we don't want to notify until after setting val ue
201 this.fire('bind-value-changed', {value: this.bindValue}); 190 this.fire('bind-value-changed', {value: this.bindValue});
202 }, 191 },
203 192
204 _onInput: function(event) { 193 _onInput: function(event) {
205 this.bindValue = event.path ? event.path[0].value : event.target.value; 194 this.bindValue = event.path ? event.path[0].value : event.target.value;
206 }, 195 },
207 196
208 _constrain: function(tokens) { 197 _constrain: function(tokens) {
(...skipping 18 matching lines...) Expand all
227 return; 216 return;
228 } 217 }
229 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&amp;') .replace(/"/gm, '&quot;').replace(/'/gm, '&#39;').replace(/</gm, '&lt;').replace (/>/gm, '&gt;').split('\n') : ['']; 218 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&amp;') .replace(/"/gm, '&quot;').replace(/'/gm, '&#39;').replace(/</gm, '&lt;').replace (/>/gm, '&gt;').split('\n') : [''];
230 return this._constrain(this.tokens); 219 return this._constrain(this.tokens);
231 }, 220 },
232 221
233 _updateCached: function() { 222 _updateCached: function() {
234 this.$.mirror.innerHTML = this._constrain(this.tokens); 223 this.$.mirror.innerHTML = this._constrain(this.tokens);
235 }, 224 },
236 225
237 _computeValue: function() { 226 _onValueChanged: function() {
238 return this.bindValue; 227 this.bindValue = this.value;
239 } 228 }
240 }); 229 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698