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

Side by Side Diff: ui/webui/resources/js/cr/ui/menu.js

Issue 485343004: Fix bookmark manager regression by allowing cr.ui.Menu#findMenuItem_ to return null. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 /** @const */ var MenuItem = cr.ui.MenuItem; 7 /** @const */ var MenuItem = cr.ui.MenuItem;
8 8
9 /** 9 /**
10 * Creates a new menu element. Menu dispatches all commands on the element it 10 * Creates a new menu element. Menu dispatches all commands on the element it
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * Walks up the ancestors of |el| until a menu item belonging to this menu 89 * Walks up the ancestors of |el| until a menu item belonging to this menu
90 * is found. 90 * is found.
91 * @param {Element} el The element to start searching from. 91 * @param {Element} el The element to start searching from.
92 * @return {cr.ui.MenuItem} The found menu item or null. 92 * @return {cr.ui.MenuItem} The found menu item or null.
93 * @private 93 * @private
94 */ 94 */
95 findMenuItem_: function(el) { 95 findMenuItem_: function(el) {
96 while (el && el.parentNode != this) { 96 while (el && el.parentNode != this) {
97 el = el.parentNode; 97 el = el.parentNode;
98 } 98 }
99 return assertInstanceof(el, MenuItem); 99 return el ? assertInstanceof(el, MenuItem) : null;
100 }, 100 },
101 101
102 /** 102 /**
103 * Handles mouseover events and selects the hovered item. 103 * Handles mouseover events and selects the hovered item.
104 * @param {Event} e The mouseover event. 104 * @param {Event} e The mouseover event.
105 * @private 105 * @private
106 */ 106 */
107 handleMouseOver_: function(e) { 107 handleMouseOver_: function(e) {
108 var overItem = this.findMenuItem_(e.target); 108 var overItem = this.findMenuItem_(e.target);
109 this.selectedItem = overItem; 109 this.selectedItem = overItem;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 * @type {number} 270 * @type {number}
271 */ 271 */
272 cr.defineProperty(Menu, 'selectedIndex', cr.PropertyKind.JS, 272 cr.defineProperty(Menu, 'selectedIndex', cr.PropertyKind.JS,
273 selectedIndexChanged); 273 selectedIndexChanged);
274 274
275 // Export 275 // Export
276 return { 276 return {
277 Menu: Menu 277 Menu: Menu
278 }; 278 };
279 }); 279 });
OLDNEW
« chrome/test/data/webui/menu_test.html ('K') | « chrome/test/data/webui/webui_resource_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698