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

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

Issue 2158913007: Roll Polymer from 1.5.0 -> 1.6.0 to pick up native CSS custom props (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 4 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 // Generate unique, monotonically increasing IDs for labels (needed by 1 // Generate unique, monotonically increasing IDs for labels (needed by
2 // aria-labelledby) and add-ons. 2 // aria-labelledby) and add-ons.
3 Polymer.PaperInputHelper = {}; 3 Polymer.PaperInputHelper = {};
4 Polymer.PaperInputHelper.NextLabelID = 1; 4 Polymer.PaperInputHelper.NextLabelID = 1;
5 Polymer.PaperInputHelper.NextAddonID = 1; 5 Polymer.PaperInputHelper.NextAddonID = 1;
6 6
7 /** 7 /**
8 * Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-con tainer>`. This 8 * Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-con tainer>`. This
9 * behavior is implemented by `<paper-input>`. It exposes a number of properti es from 9 * behavior is implemented by `<paper-input>`. It exposes a number of properti es from
10 * `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your 10 * `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 autocomplete: { 189 autocomplete: {
190 type: String, 190 type: String,
191 value: 'off' 191 value: 'off'
192 }, 192 },
193 193
194 /** 194 /**
195 * If you're using PaperInputBehavior to implement your own paper-input-li ke 195 * If you're using PaperInputBehavior to implement your own paper-input-li ke
196 * element, bind this to the `<input is="iron-input">`'s `autofocus` prope rty. 196 * element, bind this to the `<input is="iron-input">`'s `autofocus` prope rty.
197 */ 197 */
198 autofocus: { 198 autofocus: {
199 type: Boolean 199 type: Boolean,
200 observer: '_autofocusChanged'
200 }, 201 },
201 202
202 /** 203 /**
203 * If you're using PaperInputBehavior to implement your own paper-input-li ke 204 * If you're using PaperInputBehavior to implement your own paper-input-li ke
204 * element, bind this to the `<input is="iron-input">`'s `inputmode` prope rty. 205 * element, bind this to the `<input is="iron-input">`'s `inputmode` prope rty.
205 */ 206 */
206 inputmode: { 207 inputmode: {
207 type: String 208 type: String
208 }, 209 },
209 210
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // In the Shadow DOM, the `change` event is not leaked into the 507 // In the Shadow DOM, the `change` event is not leaked into the
507 // ancestor tree, so we must do this manually. 508 // ancestor tree, so we must do this manually.
508 // See https://w3c.github.io/webcomponents/spec/shadow/#events-that-are-no t-leaked-into-ancestor-trees. 509 // See https://w3c.github.io/webcomponents/spec/shadow/#events-that-are-no t-leaked-into-ancestor-trees.
509 if (this.shadowRoot) { 510 if (this.shadowRoot) {
510 this.fire(event.type, {sourceEvent: event}, { 511 this.fire(event.type, {sourceEvent: event}, {
511 node: this, 512 node: this,
512 bubbles: event.bubbles, 513 bubbles: event.bubbles,
513 cancelable: event.cancelable 514 cancelable: event.cancelable
514 }); 515 });
515 } 516 }
517 },
518
519 _autofocusChanged: function() {
520 // Firefox doesn't respect the autofocus attribute if it's applied after
521 // the page is loaded (Chrome/WebKit do respect it), preventing an
522 // autofocus attribute specified in markup from taking effect when the
523 // element is upgraded. As a workaround, if the autofocus property is set,
524 // and the focus hasn't already been moved elsewhere, we take focus.
525 if (this.autofocus && this._focusableElement) {
526
527 // In IE 11, the default document.activeElement can be the page's
528 // outermost html element, but there are also cases (under the
529 // polyfill?) in which the activeElement is not a real HTMLElement, but
530 // just a plain object. We identify the latter case as having no valid
531 // activeElement.
532 var activeElement = document.activeElement;
533 var isActiveElementValid = activeElement instanceof HTMLElement;
534
535 // Has some other element has already taken the focus?
536 var isSomeElementActive = isActiveElementValid &&
537 activeElement !== document.body &&
538 activeElement !== document.documentElement; /* IE 11 */
539 if (!isSomeElementActive) {
540 // No specific element has taken the focus yet, so we can take it.
541 this._focusableElement.focus();
542 }
543 }
516 } 544 }
517 } 545 }
518 546
519 /** @polymerBehavior */ 547 /** @polymerBehavior */
520 Polymer.PaperInputBehavior = [ 548 Polymer.PaperInputBehavior = [
521 Polymer.IronControlState, 549 Polymer.IronControlState,
522 Polymer.IronA11yKeysBehavior, 550 Polymer.IronA11yKeysBehavior,
523 Polymer.PaperInputBehaviorImpl 551 Polymer.PaperInputBehaviorImpl
524 ]; 552 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698