Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Change log
* feat: [#2989](https://github.com/gridstack/gridstack.js/pull/2989) new `updateOptions(o: GridStackOptions)` to update PARTIAL list of options after grid as been created
* fix: [#2980](https://github.com/gridstack/gridstack.js/issues/2980) dd-touch circular dependency
* fix: [#2667](https://github.com/gridstack/gridstack.js/issues/2667) sidebar items not honoring gs-w (enter-leave-re-enter)
* fix: [#2987](https://github.com/gridstack/gridstack.js/issues/2987) gs-size-to-content to support numbers

## 11.4.0 (2025-02-27)
* fix: [#2921](https://github.com/gridstack/gridstack.js/pull/2921) replace initMouseEvent with MouseEvent constructor and added composed: true
Expand Down
10 changes: 7 additions & 3 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,11 @@ export class GridStack {
n.noResize = Utils.toBool(el.getAttribute('gs-no-resize'));
n.noMove = Utils.toBool(el.getAttribute('gs-no-move'));
n.locked = Utils.toBool(el.getAttribute('gs-locked'));
n.sizeToContent = Utils.toBool(el.getAttribute('gs-size-to-content'));
const attr = el.getAttribute('gs-size-to-content');
if (attr) {
if (attr === 'true' || attr === 'false') n.sizeToContent = Utils.toBool(attr);
else n.sizeToContent = parseInt(attr, 10);
}
n.id = el.getAttribute('gs-id');

// read but never written out
Expand All @@ -1800,10 +1804,10 @@ export class GridStack {
if (n.minH) el.removeAttribute('gs-min-h');
}

// remove any key not found (null or false which is default)
// remove any key not found (null or false which is default, unless sizeToContent=false override)
for (const key in n) {
if (!n.hasOwnProperty(key)) return;
if (!n[key] && n[key] !== 0) { // 0 can be valid value (x,y only really)
if (!n[key] && n[key] !== 0 && key !== 'gs-size-to-content') { // 0 can be valid value (x,y only really)
delete n[key];
}
}
Expand Down