@@ -469,8 +469,8 @@ export class GridStack {
469469 this . _updateContainerHeight ( ) ;
470470
471471 // see if there is a sub-grid to create
472- if ( node . subGrid ) {
473- this . makeSubGrid ( node . el , undefined , undefined , false ) ; //node.subGrid will be used as option in method, no need to pass
472+ if ( node . subGridOpts ) {
473+ this . makeSubGrid ( node . el , node . subGridOpts , undefined , false ) ; // node.subGrid will be used as option in method, no need to pass
474474 }
475475
476476 // if we're adding an item into 1 column (_prevColumn is set only when going to 1) make sure
@@ -498,18 +498,18 @@ export class GridStack {
498498 if ( ! node ) {
499499 node = this . makeWidget ( el ) . gridstackNode ;
500500 }
501- if ( ( node . subGrid as GridStack ) ?. el ) return node . subGrid as GridStack ; // already done
501+ if ( node . subGrid ?. el ) return node . subGrid ; // already done
502502
503503 // find the template subGrid stored on a parent as fallback...
504504 let subGridTemplate : GridStackOptions ; // eslint-disable-next-line @typescript-eslint/no-this-alias
505505 let grid : GridStack = this ;
506506 while ( grid && ! subGridTemplate ) {
507- subGridTemplate = grid . opts ?. subGrid ;
507+ subGridTemplate = grid . opts ?. subGridOpts ;
508508 grid = grid . parentGridItem ?. grid ;
509509 }
510510 //... and set the create options
511- ops = Utils . cloneDeep ( { ...( subGridTemplate || { } ) , children : undefined , ...( ops || node . subGrid as GridStackOptions ) } ) ;
512- node . subGrid = ops ;
511+ ops = Utils . cloneDeep ( { ...( subGridTemplate || { } ) , children : undefined , ...( ops || node . subGridOpts ) } ) ;
512+ node . subGridOpts = ops ;
513513
514514 // if column special case it set, remember that flag and set default
515515 let autoColumn : boolean ;
@@ -527,7 +527,7 @@ export class GridStack {
527527 this . _removeDD ( node . el ) ; // remove D&D since it's set on content div
528528 newItemOpt = { ...node , x :0 , y :0 } ;
529529 Utils . removeInternalForSave ( newItemOpt ) ;
530- delete newItemOpt . subGrid ;
530+ delete newItemOpt . subGridOpts ;
531531 if ( node . content ) {
532532 newItemOpt . content = node . content ;
533533 delete node . content ;
@@ -625,9 +625,10 @@ export class GridStack {
625625 } else {
626626 if ( ! saveContent && ! saveCB ) { delete n . content ; }
627627 // check for nested grid
628- if ( ( n . subGrid as GridStack ) ?. el ) {
629- const listOrOpt = ( n . subGrid as GridStack ) . save ( saveContent , saveGridOpt , saveCB ) ;
630- n . subGrid = ( saveGridOpt ? listOrOpt : { children : listOrOpt } ) as GridStackOptions ;
628+ if ( n . subGrid ?. el ) {
629+ const listOrOpt = n . subGrid . save ( saveContent , saveGridOpt , saveCB ) ;
630+ n . subGridOpts = ( saveGridOpt ? listOrOpt : { children : listOrOpt } ) as GridStackOptions ;
631+ delete n . subGrid ;
631632 }
632633 }
633634 delete n . el ;
@@ -711,10 +712,10 @@ export class GridStack {
711712 let item = ( w . id || w . id === 0 ) ? this . engine . nodes . find ( n => n . id === w . id ) : undefined ;
712713 if ( item ) {
713714 this . update ( item . el , w ) ;
714- if ( w . subGrid && ( w . subGrid as GridStackOptions ) . children ) { // update any sub grid as well
715+ if ( w . subGridOpts ? .children ) { // update any sub grid as well
715716 let sub = item . el . querySelector ( '.grid-stack' ) as GridHTMLElement ;
716717 if ( sub && sub . gridstack ) {
717- sub . gridstack . load ( ( w . subGrid as GridStackOptions ) . children ) ; // TODO: support updating grid options ?
718+ sub . gridstack . load ( w . subGridOpts . children ) ; // TODO: support updating grid options ?
718719 this . _insertNotAppend = true ; // got reset by above call
719720 }
720721 }
@@ -1138,7 +1139,7 @@ export class GridStack {
11381139 this . _setupAcceptWidget ( ) ;
11391140 this . engine . nodes . forEach ( n => {
11401141 this . _prepareDragDropByNode ( n ) ; // either delete or init Drag&drop
1141- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . setStatic ( val , updateClass , recurse ) ;
1142+ if ( n . subGrid && recurse ) n . subGrid . setStatic ( val , updateClass , recurse ) ;
11421143 } ) ;
11431144 if ( updateClass ) { this . _setStaticClass ( ) ; }
11441145 return this ;
@@ -1553,7 +1554,7 @@ export class GridStack {
15531554
15541555 // finally update any nested grids
15551556 this . engine . nodes . forEach ( n => {
1556- if ( n . subGrid ) { ( n . subGrid as GridStack ) . onParentResize ( ) }
1557+ if ( n . subGrid ) n . subGrid . onParentResize ( )
15571558 } ) ;
15581559
15591560 return this ;
@@ -1757,7 +1758,7 @@ export class GridStack {
17571758 this . opts . disableDrag = ! doEnable ; // FIRST before we update children as grid overrides #1658
17581759 this . engine . nodes . forEach ( n => {
17591760 this . movable ( n . el , doEnable ) ;
1760- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . enableMove ( doEnable , recurse ) ;
1761+ if ( n . subGrid && recurse ) n . subGrid . enableMove ( doEnable , recurse ) ;
17611762 } ) ;
17621763 return this ;
17631764 }
@@ -1771,7 +1772,7 @@ export class GridStack {
17711772 this . opts . disableResize = ! doEnable ; // FIRST before we update children as grid overrides #1658
17721773 this . engine . nodes . forEach ( n => {
17731774 this . resizable ( n . el , doEnable ) ;
1774- if ( n . subGrid && recurse ) ( n . subGrid as GridStack ) . enableResize ( doEnable , recurse ) ;
1775+ if ( n . subGrid && recurse ) n . subGrid . enableResize ( doEnable , recurse ) ;
17751776 } ) ;
17761777 return this ;
17771778 }
@@ -1987,7 +1988,7 @@ export class GridStack {
19871988 if ( ! wasAdded ) return false ;
19881989 el . gridstackNode = node ;
19891990 node . el = el ;
1990- let subGrid = ( node . subGrid as GridStack ) ?. el ?. gridstack ; // set when actual sub-grid present
1991+ let subGrid = node . subGrid ?. el ?. gridstack ; // set when actual sub-grid present
19911992 // @ts -ignore
19921993 Utils . copyPos ( node , this . _readAttr ( this . placeholder ) ) ; // placeholder values as moving VERY fast can throw things off #1578
19931994 Utils . removePositioningStyles ( el ) ; // @ts -ignore
@@ -2263,7 +2264,7 @@ export class GridStack {
22632264 node . _lastUiPosition = ui . position ;
22642265 this . engine . cacheRects ( cellWidth , cellHeight , mTop , mRight , mBottom , mLeft ) ;
22652266 delete node . _skipDown ;
2266- if ( resizing && node . subGrid ) { ( node . subGrid as GridStack ) . onParentResize ( ) ; } // @ts -ignore
2267+ if ( resizing && node . subGrid ) node . subGrid . onParentResize ( ) ;
22672268 this . _extraDragRow = 0 ; // @ts -ignore
22682269 this . _updateContainerHeight ( ) ;
22692270
0 commit comments