@@ -242,13 +242,12 @@ export class GridStack {
242242
243243 this . _initStyles ( ) ;
244244
245- this . engine = new GridStackEngine ( this . opts . column , ( cbNodes , detachNode ) => {
246- detachNode = ( detachNode === undefined ? true : detachNode ) ;
245+ this . engine = new GridStackEngine ( this . opts . column , ( cbNodes , removeDOM = true ) => {
247246 let maxHeight = 0 ;
248247 this . engine . nodes . forEach ( n => { maxHeight = Math . max ( maxHeight , n . y + n . height ) } ) ;
249248 cbNodes . forEach ( n => {
250249 let el = n . el ;
251- if ( detachNode && n . _id === null ) {
250+ if ( removeDOM && n . _id === null ) {
252251 if ( el && el . parentNode ) { el . parentNode . removeChild ( el ) }
253252 } else {
254253 this . _writeAttrs ( el , n . x , n . y , n . width , n . height ) ;
@@ -466,13 +465,13 @@ export class GridStack {
466465
467466 /**
468467 * Destroys a grid instance.
469- * @param detachGrid if false nodes and grid will not be removed from the DOM (Optional. Default true).
468+ * @param removeDOM if ` false` grid and items elements will not be removed from the DOM (Optional. Default ` true` ).
470469 */
471- public destroy ( detachGrid = true ) : GridStack {
470+ public destroy ( removeDOM = true ) : GridStack {
472471 window . removeEventListener ( 'resize' , this . _onResizeHandler ) ;
473472 this . disable ( ) ;
474- if ( ! detachGrid ) {
475- this . removeAll ( false ) ;
473+ if ( ! removeDOM ) {
474+ this . removeAll ( removeDOM ) ;
476475 this . el . classList . remove ( this . opts . _class ) ;
477476 delete this . el . gridstack ;
478477 } else {
@@ -825,9 +824,9 @@ export class GridStack {
825824 /**
826825 * Removes widget from the grid.
827826 * @param el widget or selector to modify
828- * @param detachNode if false DOM node won't be removed from the tree (Default? true).
827+ * @param removeDOM if ` false` DOM element won't be removed from the tree (Default? true).
829828 */
830- public removeWidget ( els : GridStackElement , detachNode = true ) : GridStack {
829+ public removeWidget ( els : GridStackElement , removeDOM = true ) : GridStack {
831830 this . getElements ( els ) . forEach ( el => {
832831 if ( el . parentElement !== this . el ) return ; // not our child!
833832 let node = el . gridstackNode ;
@@ -841,7 +840,7 @@ export class GridStack {
841840 delete el . gridstackNode ;
842841 this . dd . draggable ( el , 'destroy' ) . resizable ( el , 'destroy' ) ;
843842
844- this . engine . removeNode ( node , detachNode , true ) ; // true for trigger event
843+ this . engine . removeNode ( node , removeDOM , true ) ; // true for trigger event
845844 } ) ;
846845 this . _triggerRemoveEvent ( ) ;
847846 this . _triggerChangeEvent ( ) ;
@@ -850,15 +849,15 @@ export class GridStack {
850849
851850 /**
852851 * Removes all widgets from the grid.
853- * @param detachNode if false DOM nodes won't be removed from the tree (Default? true).
852+ * @param removeDOM if ` false` DOM elements won't be removed from the tree (Default? ` true` ).
854853 */
855- public removeAll ( detachNode ?: boolean ) : GridStack {
854+ public removeAll ( removeDOM = true ) : GridStack {
856855 // always remove our DOM data (circular link) before list gets emptied and drag&drop permanently
857856 this . engine . nodes . forEach ( n => {
858857 delete n . el . gridstackNode ;
859858 this . dd . draggable ( n . el , 'destroy' ) . resizable ( n . el , 'destroy' ) ;
860859 } ) ;
861- this . engine . removeAll ( detachNode ) ;
860+ this . engine . removeAll ( removeDOM ) ;
862861 this . _triggerRemoveEvent ( ) ;
863862 return this ;
864863 }
0 commit comments