* Creates a new menu item element.
* @param {Object=} opt_propertyBag Optional properties.
* @constructor
- * @extends {HTMLDivElement}
+ * @extends {HTMLButtonElement}
+ * @implements {EventListener}
*/
var MenuItem = cr.ui.define('div');
}
if (typeof command == 'string' && command[0] == '#') {
- command = this.ownerDocument.getElementById(command.slice(1));
+ command = assert(this.ownerDocument.getElementById(command.slice(1)));
cr.ui.decorate(command, Command);
}
updateShortcut_: function() {
this.removeAttribute('shortcutText');
- if (!(this.command_ && this.command_.shortcut))
+ if (!this.command_ ||
+ !this.command_.shortcut ||
+ this.command_.hideShortcutText)
return;
var shortcuts = this.command_.shortcut.split(/\s+/);
/**
* Handles mouseup events. This dispatches an activate event; if there is an
* associated command, that command is executed.
- * @param {Event} e The mouseup event object.
+ * @param {!Event} e The mouseup event object.
* @private
*/
handleMouseUp_: function(e) {
+ e = /** @type {!MouseEvent} */(e);
// Only dispatch an activate event for left or middle click.
if (e.button > 1)
return;
/**
* Whether the menu item is disabled or not.
- * @type {boolean}
*/
cr.defineProperty(MenuItem, 'disabled', cr.PropertyKind.BOOL_ATTR);
/**
* Whether the menu item is hidden or not.
- * @type {boolean}
*/
cr.defineProperty(MenuItem, 'hidden', cr.PropertyKind.BOOL_ATTR);
/**
* Whether the menu item is selected or not.
- * @type {boolean}
*/
cr.defineProperty(MenuItem, 'selected', cr.PropertyKind.BOOL_ATTR);
/**
* Whether the menu item is checked or not.
- * @type {boolean}
*/
cr.defineProperty(MenuItem, 'checked', cr.PropertyKind.BOOL_ATTR);
/**
* Whether the menu item is checkable or not.
- * @type {boolean}
*/
cr.defineProperty(MenuItem, 'checkable', cr.PropertyKind.BOOL_ATTR);