Skip to content

BaseMenuItem

A basic navigation link contained inside of a BaseMenu.

Constructor

Constructs a new BaseMenuItem.

js
new BaseMenuItem({
  menuItemElement,
  menuLinkElement,
  parentMenu,
  isSubmenuItem,
  childMenu,
  toggle,
});

The constructor populates the dom, elements, and submenu properties. It will not initialize the menu item; this is left to the subclasses to evoke.

Parameters

NameTypeDescriptionDefault
optionsobjectThe options for generating the menu item.undefined
options.menuItemElementHTMLElementThe menu item in the DOM.undefined
options.menuLinkElementHTMLElementThe menu item's link in the DOM.undefined
options.parentMenuBaseMenuThe parent menu.undefined
options.isSubmenuItembooleanA flag to mark if the menu item is controlling a submenu.false
options.childMenuBaseMenu, nullThe child menu.null
options.toggleBaseMenuToggle, nullThe controller for the child menu.null

Initialize

Initialize the menu item.

js
BaseMenuItem.initialize();

This method is a placeholder for subclasses to expand upon. The BaseMenuItem's initialize method does nothing.

Properties

_dom protected

The DOM elements within the menu item.

js
BaseMenuItem._dom;

Type

Object<HTMLElement>

Properties

NameTypeDescriptionDefault
itemHTMLElementThe menu item.null
linkHTMLElementThe menu item's link.null

_elements protected

The declared accessible-menu elements within the menu item.

js
BaseMenuItem._elements;

Type

Object<BaseMenu, BaseMenuToggle>

Properties

NameTypeDescriptionDefault
parentMenuBaseMenuThe menu containing this menu item.null
childMenuBaseMenu, nullThe menu contained within this menu item.null
toggleBaseMenuToggle, nullThe menu toggle within this menu item that controls the childMenu.null

_submenu protected

A flag marking a submenu item.

js
BaseMenuItem._submenu; // Default: `false`.

Type

boolean

Getters and Setters

dom readonly

The DOM elements within the menu item.

js
BaseMenuItem.dom;

See _dom for more information.

elements readonly

The declared accessible-menu elements within the menu item.

js
BaseMenuItem.elements;

See _elements for more information.

isSubmenuItem readonly

A flag marking a submenu item.

js
BaseMenuItem.isSubmenuItem;

See _submenu for more information.

Methods

focus public

Focuses the menu item's link if the parent menu's shouldFocus value is true.

js
BaseMenuItem.focus();

blur public

Blurs the menu item's link if the parent menu's shouldFocus value is true.

js
BaseMenuItem.blur();