@@ -1464,14 +1464,12 @@ export class GridStack {
14641464 }
14651465
14661466 /** @internal call to read any default attributes from element */
1467- protected _readAttr ( el : HTMLElement ) : GridStackWidget {
1467+ protected _readAttr ( el : HTMLElement , clearDefaultAttr = true ) : GridStackWidget {
14681468 let n : GridStackNode = { } ;
14691469 n . x = Utils . toNumber ( el . getAttribute ( 'gs-x' ) ) ;
14701470 n . y = Utils . toNumber ( el . getAttribute ( 'gs-y' ) ) ;
14711471 n . w = Utils . toNumber ( el . getAttribute ( 'gs-w' ) ) ;
14721472 n . h = Utils . toNumber ( el . getAttribute ( 'gs-h' ) ) ;
1473- if ( ! ( n . w > 1 ) ) el . removeAttribute ( 'gs-w' ) ;
1474- if ( ! ( n . h > 1 ) ) el . removeAttribute ( 'gs-h' ) ;
14751473 n . autoPosition = Utils . toBool ( el . getAttribute ( 'gs-auto-position' ) ) ;
14761474 n . noResize = Utils . toBool ( el . getAttribute ( 'gs-no-resize' ) ) ;
14771475 n . noMove = Utils . toBool ( el . getAttribute ( 'gs-no-move' ) ) ;
@@ -1480,13 +1478,19 @@ export class GridStack {
14801478
14811479 // read but never written out
14821480 n . maxW = Utils . toNumber ( el . getAttribute ( 'gs-max-w' ) ) ;
1483- if ( n . maxW ) el . removeAttribute ( 'gs-max-w' ) ;
14841481 n . minW = Utils . toNumber ( el . getAttribute ( 'gs-min-w' ) ) ;
1485- if ( n . minW ) el . removeAttribute ( 'gs-min-w' ) ;
14861482 n . maxH = Utils . toNumber ( el . getAttribute ( 'gs-max-h' ) ) ;
1487- if ( n . maxH ) el . removeAttribute ( 'gs-max-h' ) ;
14881483 n . minH = Utils . toNumber ( el . getAttribute ( 'gs-min-h' ) ) ;
1489- if ( n . minH ) el . removeAttribute ( 'gs-min-h' ) ;
1484+
1485+ // v8.x optimization to reduce un-needed attr that don't render or are default CSS
1486+ if ( clearDefaultAttr ) {
1487+ if ( n . w === 1 ) el . removeAttribute ( 'gs-w' ) ;
1488+ if ( n . h === 1 ) el . removeAttribute ( 'gs-h' ) ;
1489+ if ( n . maxW ) el . removeAttribute ( 'gs-max-w' ) ;
1490+ if ( n . minW ) el . removeAttribute ( 'gs-min-w' ) ;
1491+ if ( n . maxH ) el . removeAttribute ( 'gs-max-h' ) ;
1492+ if ( n . minH ) el . removeAttribute ( 'gs-min-h' ) ;
1493+ }
14901494
14911495 // remove any key not found (null or false which is default)
14921496 for ( const key in n ) {
@@ -1884,8 +1888,8 @@ export class GridStack {
18841888 cellHeight = this . getCellHeight ( true ) ;
18851889
18861890 // load any element attributes if we don't have a node
1887- if ( ! node ) { // @ts -ignore private read only on ourself
1888- node = this . _readAttr ( el ) ;
1891+ if ( ! node ) {
1892+ node = this . _readAttr ( el , false ) ; // don't wipe external (e.g. drag toolbar) attr #2354
18891893 }
18901894 if ( ! node . grid ) {
18911895 node . _isExternal = true ;
0 commit comments