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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
index cbdb805238762cbacbb8a05b4f6d149961780360..8ae94d9d1eefb66542c27b4c98a284116b4eeb79 100644
--- a/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js
@@ -196,7 +196,8 @@
* element, bind this to the `<input is="iron-input">`'s `autofocus` property.
*/
autofocus: {
- type: Boolean
+ type: Boolean,
+ observer: '_autofocusChanged'
},
/**
@@ -513,6 +514,33 @@
cancelable: event.cancelable
});
}
+ },
+
+ _autofocusChanged: function() {
+ // Firefox doesn't respect the autofocus attribute if it's applied after
+ // the page is loaded (Chrome/WebKit do respect it), preventing an
+ // autofocus attribute specified in markup from taking effect when the
+ // element is upgraded. As a workaround, if the autofocus property is set,
+ // and the focus hasn't already been moved elsewhere, we take focus.
+ if (this.autofocus && this._focusableElement) {
+
+ // In IE 11, the default document.activeElement can be the page's
+ // outermost html element, but there are also cases (under the
+ // polyfill?) in which the activeElement is not a real HTMLElement, but
+ // just a plain object. We identify the latter case as having no valid
+ // activeElement.
+ var activeElement = document.activeElement;
+ var isActiveElementValid = activeElement instanceof HTMLElement;
+
+ // Has some other element has already taken the focus?
+ var isSomeElementActive = isActiveElementValid &&
+ activeElement !== document.body &&
+ activeElement !== document.documentElement; /* IE 11 */
+ if (!isSomeElementActive) {
+ // No specific element has taken the focus yet, so we can take it.
+ this._focusableElement.focus();
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698