2020-07-28 17:48:40 +08:00
|
|
|
import MenuItem from './menu-item'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
|
|
|
import type { RendererNode } from 'vue'
|
2020-07-28 17:48:40 +08:00
|
|
|
|
|
|
|
class Menu {
|
2020-11-12 14:43:55 +08:00
|
|
|
constructor(public domNode: RendererNode) {
|
2020-07-28 17:48:40 +08:00
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
init(): void {
|
2020-11-12 14:43:55 +08:00
|
|
|
const menuChildren = this.domNode.childNodes
|
2021-09-12 17:46:55 +08:00
|
|
|
Array.from(menuChildren, (child: Node) => {
|
|
|
|
if (child.nodeType === 1) {
|
2020-11-12 14:43:55 +08:00
|
|
|
new MenuItem(child as HTMLElement)
|
2021-09-12 17:46:55 +08:00
|
|
|
}
|
|
|
|
})
|
2020-07-28 17:48:40 +08:00
|
|
|
}
|
|
|
|
}
|
2021-09-12 17:46:55 +08:00
|
|
|
|
2020-07-28 17:48:40 +08:00
|
|
|
export default Menu
|