Index: ui/webui/resources/js/cr/ui/menu.js |
diff --git a/ui/webui/resources/js/cr/ui/menu.js b/ui/webui/resources/js/cr/ui/menu.js |
index 6784910acb732879261b9cd2c02c6b67698bd4a5..22d93b4dba6db32f07f4e4b3a61be7454d807ddf 100644 |
--- a/ui/webui/resources/js/cr/ui/menu.js |
+++ b/ui/webui/resources/js/cr/ui/menu.js |
@@ -221,12 +221,15 @@ cr.define('cr.ui', function() { |
case 'Enter': |
case 'U+0020': // Space |
if (item) { |
+ // Store |contextElement| since it'll be removed when handling the |
+ // 'activate' event. |
+ var contextElement = this.contextElement; |
var activationEvent = cr.doc.createEvent('Event'); |
activationEvent.initEvent('activate', true, true); |
activationEvent.originalEvent = e; |
if (item.dispatchEvent(activationEvent)) { |
if (item.command) |
- item.command.execute(); |
+ item.command.execute(contextElement); |
} |
} |
return true; |