@@ -1464,14 +1464,12 @@ export class GridStack {
1464
1464
}
1465
1465
1466
1466
/** @internal call to read any default attributes from element */
1467
- protected _readAttr ( el : HTMLElement ) : GridStackWidget {
1467
+ protected _readAttr ( el : HTMLElement , clearDefaultAttr = true ) : GridStackWidget {
1468
1468
let n : GridStackNode = { } ;
1469
1469
n . x = Utils . toNumber ( el . getAttribute ( 'gs-x' ) ) ;
1470
1470
n . y = Utils . toNumber ( el . getAttribute ( 'gs-y' ) ) ;
1471
1471
n . w = Utils . toNumber ( el . getAttribute ( 'gs-w' ) ) ;
1472
1472
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' ) ;
1475
1473
n . autoPosition = Utils . toBool ( el . getAttribute ( 'gs-auto-position' ) ) ;
1476
1474
n . noResize = Utils . toBool ( el . getAttribute ( 'gs-no-resize' ) ) ;
1477
1475
n . noMove = Utils . toBool ( el . getAttribute ( 'gs-no-move' ) ) ;
@@ -1480,13 +1478,19 @@ export class GridStack {
1480
1478
1481
1479
// read but never written out
1482
1480
n . maxW = Utils . toNumber ( el . getAttribute ( 'gs-max-w' ) ) ;
1483
- if ( n . maxW ) el . removeAttribute ( 'gs-max-w' ) ;
1484
1481
n . minW = Utils . toNumber ( el . getAttribute ( 'gs-min-w' ) ) ;
1485
- if ( n . minW ) el . removeAttribute ( 'gs-min-w' ) ;
1486
1482
n . maxH = Utils . toNumber ( el . getAttribute ( 'gs-max-h' ) ) ;
1487
- if ( n . maxH ) el . removeAttribute ( 'gs-max-h' ) ;
1488
1483
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
+ }
1490
1494
1491
1495
// remove any key not found (null or false which is default)
1492
1496
for ( const key in n ) {
@@ -1884,8 +1888,8 @@ export class GridStack {
1884
1888
cellHeight = this . getCellHeight ( true ) ;
1885
1889
1886
1890
// 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
1889
1893
}
1890
1894
if ( ! node . grid ) {
1891
1895
node . _isExternal = true ;
0 commit comments