@@ -260,10 +260,10 @@ export const ItemsMixin = (superClass) =>
260260 }
261261
262262 /** @private */
263- __initSubMenu ( subMenu ) {
264- this . _subMenu = subMenu ;
263+ __initSubMenu ( ) {
264+ const subMenu = document . createElement ( this . constructor . is ) ;
265265
266- subMenu . $ . overlay . modeless = true ;
266+ subMenu . _modeless = true ;
267267 subMenu . openOn = 'opensubmenu' ;
268268
269269 // Sub-menu doesn't have a target to wrap,
@@ -307,6 +307,8 @@ export const ItemsMixin = (superClass) =>
307307 }
308308 }
309309 } ) ;
310+
311+ return subMenu ;
310312 }
311313
312314 /** @private */
@@ -328,14 +330,16 @@ export const ItemsMixin = (superClass) =>
328330 const subMenu = this . _subMenu ;
329331
330332 if ( item ) {
331- if ( subMenu . items !== item . _item . children ) {
333+ const { children } = item . _item ;
334+
335+ if ( subMenu . items !== children ) {
332336 subMenu . close ( ) ;
333337 }
334338 if ( ! this . opened ) {
335339 return ;
336340 }
337341
338- if ( item . _item . children && item . _item . children . length ) {
342+ if ( children && children . length ) {
339343 this . __updateExpanded ( item , true ) ;
340344
341345 // Forward parent overlay class
@@ -353,19 +357,16 @@ export const ItemsMixin = (superClass) =>
353357 * @param {!ContextMenuRendererContext } context
354358 * @protected
355359 */
356- __itemsRenderer ( root , menu , context ) {
360+ __itemsRenderer ( root , menu , { detail } ) {
357361 this . __initMenu ( root , menu ) ;
358362
359363 const subMenu = root . querySelector ( this . constructor . is ) ;
360364 subMenu . closeOn = menu . closeOn ;
361365
362366 const listBox = root . querySelector ( `${ this . _tagNamePrefix } -list-box` ) ;
363-
364367 listBox . innerHTML = '' ;
365368
366- const items = Array . from ( context . detail . children || menu . items ) ;
367-
368- items . forEach ( ( item ) => {
369+ [ ...( detail . children || menu . items ) ] . forEach ( ( item ) => {
369370 const component = this . __createComponent ( item ) ;
370371 listBox . appendChild ( component ) ;
371372 } ) ;
@@ -407,10 +408,9 @@ export const ItemsMixin = (superClass) =>
407408 this . _listBox = listBox ;
408409 root . appendChild ( listBox ) ;
409410
410- const subMenu = document . createElement ( this . constructor . is ) ;
411- // Append before accessing the overlay
411+ const subMenu = this . __initSubMenu ( ) ;
412+ this . _subMenu = subMenu ;
412413 root . appendChild ( subMenu ) ;
413- this . __initSubMenu ( subMenu ) ;
414414
415415 requestAnimationFrame ( ( ) => {
416416 this . __openListenerActive = true ;
0 commit comments