element-plus/packages/utils/menu/menu-bar.ts

20 lines
389 B
TypeScript
Raw Normal View History

2020-07-28 17:48:40 +08:00
import MenuItem from './menu-item'
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
Array.from(menuChildren, (child: Node) => {
if (child.nodeType === 1) {
2020-11-12 14:43:55 +08:00
new MenuItem(child as HTMLElement)
}
})
2020-07-28 17:48:40 +08:00
}
}
2020-07-28 17:48:40 +08:00
export default Menu