@@ -20,9 +20,9 @@ export default class Menu extends BaseElement {
2020 this . style . backgroundColor = '' ;
2121 } ) ;
2222
23- this . menuItems = createDiv ( { className : `${ classes [ 'menuItems ' ] } ${ classes [ 'hidden' ] } ` } ) ;
23+ this . menuItemsDiv = createDiv ( { className : `${ classes [ 'menuItemsDiv ' ] } ${ classes [ 'hidden' ] } ` } ) ;
2424
25- this . items . forEach ( ( item ) => {
25+ this . items . forEach ( ( item , idx ) => {
2626 const { label, element, callback } = item ;
2727 const labelElem = element || createLabel ( {
2828 className : `${ classes [ 'fontNormal' ] } ${ classes [ 'fontHeavy' ] } ` ,
@@ -37,15 +37,15 @@ export default class Menu extends BaseElement {
3737 }
3838
3939 itemElem . appendChild ( labelElem ) ;
40- this . menuItems . appendChild ( itemElem ) ;
40+ this . menuItemsDiv . appendChild ( itemElem ) ;
4141
42- if ( this . divider && item !== this . items [ this . items . length - 1 ] ) {
42+ if ( this . divider && idx < ( this . items . length - 1 ) ) {
4343 const divider = this . divider . cloneNode ( true ) ;
44- this . menuItems . appendChild ( divider ) ;
44+ this . menuItemsDiv . appendChild ( divider ) ;
4545 }
4646 } ) ;
4747
48- this . element . appendChild ( this . menuItems ) ;
48+ this . element . appendChild ( this . menuItemsDiv ) ;
4949 this . element . onclick = ( e ) => {
5050 e . stopPropagation ( ) ;
5151 if ( this . opened ) {
@@ -61,12 +61,12 @@ export default class Menu extends BaseElement {
6161 }
6262
6363 show ( ) {
64- this . menuItems . classList . remove ( classes [ 'hidden' ] ) ;
64+ this . menuItemsDiv . classList . remove ( classes [ 'hidden' ] ) ;
6565 this . opened = true ;
6666 }
6767
6868 hide ( ) {
69- this . menuItems . classList . add ( classes [ 'hidden' ] ) ;
69+ this . menuItemsDiv . classList . add ( classes [ 'hidden' ] ) ;
7070 this . opened = false ;
7171 }
7272}
0 commit comments