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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js

Issue 1901343004: [Polymer] update third_party polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new pull Created 4 years, 8 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/iron-menu-behavior/iron-menu-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
index e8b03e9e97eadee3c144ba4288ea6b96e92832d2..55c59dd672c345d63fae66bc3cf447dbbd6fe1f2 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
@@ -112,7 +112,8 @@
var attr = this.attrForItemTitle || 'textContent';
var title = item[attr] || item.getAttribute(attr);
- if (title && title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.keyCode).toLowerCase()) {
+ if (!item.hasAttribute('disabled') && title &&
+ title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.keyCode).toLowerCase()) {
this._setFocusedItem(item);
break;
}
@@ -121,21 +122,34 @@
/**
* Focuses the previous item (relative to the currently focused item) in the
- * menu.
+ * menu, disabled items will be skipped.
*/
_focusPrevious: function() {
var length = this.items.length;
- var index = (Number(this.indexOf(this.focusedItem)) - 1 + length) % length;
- this._setFocusedItem(this.items[index]);
+ var curFocusIndex = Number(this.indexOf(this.focusedItem));
+ for (var i = 1; i < length; i++) {
+ var item = this.items[(curFocusIndex - i + length) % length];
+ if (!item.hasAttribute('disabled')) {
+ this._setFocusedItem(item);
+ return;
+ }
+ }
},
/**
* Focuses the next item (relative to the currently focused item) in the
- * menu.
+ * menu, disabled items will be skipped.
*/
_focusNext: function() {
- var index = (Number(this.indexOf(this.focusedItem)) + 1) % this.items.length;
- this._setFocusedItem(this.items[index]);
+ var length = this.items.length;
+ var curFocusIndex = Number(this.indexOf(this.focusedItem));
+ for (var i = 1; i < length; i++) {
+ var item = this.items[(curFocusIndex + i) % length];
+ if (!item.hasAttribute('disabled')) {
+ this._setFocusedItem(item);
+ return;
+ }
+ }
},
/**
@@ -244,7 +258,8 @@
if (selectedItem) {
this._setFocusedItem(selectedItem);
} else if (this.items[0]) {
- this._setFocusedItem(this.items[0]);
+ // We find the first none-disabled item (if one exists)
+ this._focusNext();
}
});
},

Powered by Google App Engine
This is Rietveld 408576698