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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js

Issue 1187823002: Update Polymer components and re-run reproduce.sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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 1
2 2
3 /** 3 /**
4 * Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-con tainer>`. This 4 * Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-con tainer>`. This
5 * behavior is implemented by `<paper-input>`. It exposes a number of properti es from 5 * behavior is implemented by `<paper-input>`. It exposes a number of properti es from
6 * `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your 6 * `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your
7 * template. 7 * template.
8 * 8 *
9 * The input element can be accessed by the `inputElement` property if you nee d to access 9 * The input element can be accessed by the `inputElement` property if you nee d to access
10 * properties or methods that are not exposed. 10 * properties or methods that are not exposed.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 * Bind this to the `<input is="iron-input">`'s `name` property. 183 * Bind this to the `<input is="iron-input">`'s `name` property.
184 */ 184 */
185 name: { 185 name: {
186 type: String 186 type: String
187 }, 187 },
188 188
189 /** 189 /**
190 * A placeholder string in addition to the label. If this is set, the labe l will always float. 190 * A placeholder string in addition to the label. If this is set, the labe l will always float.
191 */ 191 */
192 placeholder: { 192 placeholder: {
193 type: String 193 type: String,
194 // need to set a default so _computeAlwaysFloatLabel is run
195 value: ''
194 }, 196 },
195 197
196 /** 198 /**
197 * Bind this to the `<input is="iron-input">`'s `readonly` property. 199 * Bind this to the `<input is="iron-input">`'s `readonly` property.
198 */ 200 */
199 readonly: { 201 readonly: {
200 type: Boolean, 202 type: Boolean,
201 value: false 203 value: false
202 }, 204 },
203 205
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } else { 248 } else {
247 var id = 'paper-input-add-on-' + Math.floor((Math.random() * 100000)); 249 var id = 'paper-input-add-on-' + Math.floor((Math.random() * 100000));
248 target.id = id; 250 target.id = id;
249 this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedB y, id); 251 this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedB y, id);
250 } 252 }
251 }, 253 },
252 254
253 /** 255 /**
254 * Validates the input element and sets an error style if needed. 256 * Validates the input element and sets an error style if needed.
255 */ 257 */
256 validate: function () { 258 validate: function() {
257 return this.inputElement.validate(); 259 return this.inputElement.validate();
258 }, 260 },
259 261
262 /**
263 * Restores the cursor to its original position after updating the value.
264 * @param {string} newValue The value that should be saved.
265 */
266 updateValueAndPreserveCaret: function(newValue) {
267 // Not all elements might have selection, and even if they have the
268 // right properties, accessing them might throw an exception (like for
269 // <input type=number>)
270 try {
271 var start = this.inputElement.selectionStart;
272 this.value = newValue;
273
274 // The cursor automatically jumps to the end after re-setting the value,
275 // so restore it to its original position.
276 this.inputElement.selectionStart = start;
277 this.inputElement.selectionEnd = start;
278 } catch (e) {
279 // Just set the value and give up on the caret.
280 this.value = newValue;
281 }
282 },
283
260 _computeAlwaysFloatLabel: function(alwaysFloatLabel, placeholder) { 284 _computeAlwaysFloatLabel: function(alwaysFloatLabel, placeholder) {
261 return placeholder || alwaysFloatLabel; 285 return placeholder || alwaysFloatLabel;
262 }, 286 },
263 287
264 _updateAriaLabelledBy: function() { 288 _updateAriaLabelledBy: function() {
265 var label = Polymer.dom(this.root).querySelector('label'); 289 var label = Polymer.dom(this.root).querySelector('label');
266 if (!label) { 290 if (!label) {
267 this._ariaLabelledBy = ''; 291 this._ariaLabelledBy = '';
268 return; 292 return;
269 } 293 }
270 var labelledBy; 294 var labelledBy;
271 if (label.id) { 295 if (label.id) {
272 labelledBy = label.id; 296 labelledBy = label.id;
273 } else { 297 } else {
274 labelledBy = 'paper-input-label-' + new Date().getUTCMilliseconds(); 298 labelledBy = 'paper-input-label-' + new Date().getUTCMilliseconds();
275 label.id = labelledBy; 299 label.id = labelledBy;
276 } 300 }
277 this._ariaLabelledBy = labelledBy; 301 this._ariaLabelledBy = labelledBy;
278 } 302 }
279 303
280 }; 304 };
281 305
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698