accessible-menu
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
@@ -5,2 +5,24 @@ # Changelog | ||
## [1.0.0-alpha.1](https://github.com/NickDJM/accessible-menu/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2019-11-17) | ||
### ⚠ BREAKING CHANGES | ||
* **menu:** The submenuItem class no longer exists, and the menuToggle class has been added. | ||
### Bug Fixes | ||
* **menu:** properly exit menu on escape ([b5113e9](https://github.com/NickDJM/accessible-menu/commit/b5113e9bea30c412192526efdc8d3bb0be8e45c0)) | ||
* **package:** correct entry point to ([de6b439](https://github.com/NickDJM/accessible-menu/commit/de6b439cf37c1d2568a1ef94eae1dba63a659551)), closes [#12](https://github.com/NickDJM/accessible-menu/issues/12) | ||
### Documentation | ||
* **readme:** add release and license badges ([cea2814](https://github.com/NickDJM/accessible-menu/commit/cea2814b5e971463acca9ad02e05b8b3043f3cb6)) | ||
### Code Refactoring | ||
* **menu:** replace submenuItem with menuToggle ([e43ad22](https://github.com/NickDJM/accessible-menu/commit/e43ad220962766b284f6cc33277bf194013fde13)) | ||
## 1.0.0-alpha.0 (2019-11-17) | ||
@@ -7,0 +29,0 @@ |
{ | ||
"name": "accessible-menu", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus in the DOM.", | ||
"main": "index.js", | ||
"main": "src/menu.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "commit": "npx git cz", |
# accessible-menu | ||
[![Latest release](https://img.shields.io/github/v/release/NickDJM/accessible-menu?include_prereleases&style=for-the-badge)](https://github.com/NickDJM/accessible-menu/releases) | ||
[![License](https://img.shields.io/github/license/NickDJM/accessible-menu?style=for-the-badge)](/LICENSE) | ||
A JavaScript library to help you generate WAI-ARIA accessible menus in the DOM. | ||
@@ -4,0 +7,0 @@ |
import MenuItem from "menuItem.js"; | ||
import SubmenuItem from "submenuItem.js"; | ||
import MenuToggle from "menuToggle.js"; | ||
@@ -40,3 +40,3 @@ export class Menu { | ||
menuItems: [], | ||
submenuItems: [] | ||
menuToggles: [] | ||
}; | ||
@@ -101,8 +101,8 @@ this.focussedChild = -1; | ||
/** | ||
* The submenu items contained in the menu. | ||
* The menu toggles contained in the menu. | ||
* | ||
* @returns {SubmenuItem[]} - The submenu items. | ||
* @returns {MenuToggle[]} - The menu toggles. | ||
*/ | ||
get submenuItems() { | ||
return this.element.submenuItems; | ||
get menuToggles() { | ||
return this.elements.menuToggles; | ||
} | ||
@@ -170,4 +170,11 @@ | ||
this.menuItemElements.forEach(element => { | ||
let menuItem; | ||
// Create a new MenuItem. | ||
const menuItem = new MenuItem(element, this); | ||
// Add the item to the list of menu items. | ||
this.elements.menuItems.push(menuItem); | ||
// Initialize the menu item. | ||
menuItem.initialize(); | ||
// If the menu item is a dropdown, create a SubmenuItem, | ||
@@ -192,23 +199,15 @@ // otherwise create a normal MenuItem. | ||
// Create a new SubmenuItem. | ||
menuItem = new SubmenuItem( | ||
element, | ||
this, | ||
// Create the new MenuToggle. | ||
const toggle = new MenuToggle( | ||
toggler, | ||
menu, | ||
this.openClass | ||
this.openClass, | ||
this, | ||
menuItem | ||
); | ||
toggle.initialize(); | ||
// Add it to the list of submenu items. | ||
this.elements.submenuItems.push(menuItem); | ||
} else { | ||
// Create a new MenuItem. | ||
menuItem = new MenuItem(element, this); | ||
this.elements.menuToggles.push(toggle); | ||
} | ||
// Add the item to the list of menu items. | ||
this.elements.menuItems.push(menuItem); | ||
// Initialize the menu item. | ||
menuItem.initialize(); | ||
}); | ||
@@ -245,4 +244,4 @@ } | ||
preventDefault(event); | ||
this.focus(); | ||
this.currentFocus = "none"; | ||
this.focus(); | ||
} else if (key === "ArrowDown" || (key === "Tab" && !shiftKey)) { | ||
@@ -274,3 +273,6 @@ // The Down Arrow and Tab keys should focus the next menu item. | ||
document.addEventListener("click", event => { | ||
if (!this.element.contains(event.target)) { | ||
if ( | ||
!this.element.contains(event.target) && | ||
this.element !== event.target | ||
) { | ||
this.blur(); | ||
@@ -353,4 +355,4 @@ this.closeChildren(); | ||
closeChildren() { | ||
this.elements.submenuItems.forEach(submenu => submenu.close()); | ||
this.menuToggles.forEach(toggle => toggle.close()); | ||
} | ||
} |
@@ -52,3 +52,3 @@ import Menu from "menu.js"; | ||
*/ | ||
get parent() { | ||
get parentMenu() { | ||
return this.elements.parent; | ||
@@ -55,0 +55,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30720
595
65