Skip to content

Commit 9ab6920

Browse files
committed
use attr data-gs-widget
* fix #2900 * use attr `data-gs-widget` instead of `gridstacknode` (supported as well for backward compatibility)
1 parent a2285e6 commit 9ab6920

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

demo/two.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ <h1>Two grids demo</h1>
3030
<!-- constrained in code using GridStackWidget[] sidebarContent -->
3131
<div class="sidebar-item">2x1, max=3</div>
3232
<!-- DOM JSON spelling GridStackWidget. NOTE: require content:'xyz' to work and RenderCB() to render -->
33-
<div class="sidebar-item" gridstacknode='{"w":3, "content":"w:3"}'>w:3</div>
33+
<div class="sidebar-item" data-gs-widget='{"w":3, "content":"drop w:3"}'>w:3</div>
3434
<!-- DOM id handled by myClone() case -->
3535
<div class="sidebar-item" gs-id="manual">gs-id case</div>
3636
<!-- DOM require proper GS format to be dropped as is without GridStackWidget above -->
3737
<div class="grid-stack-item" gs-w="3">
3838
<div class="grid-stack-item-content">DOM gs-w:3</div>
3939
</div>
40-
<div class="grid-stack-item" gridstacknode='{"w":2}'>
40+
<div class="grid-stack-item" data-gs-widget='{"w":2}'>
4141
<div class="grid-stack-item-content">DOM w:2</div>
4242
</div>
4343
</div>

doc/CHANGES.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [11.1.2-dev (TBD)](#1112-dev-tbd)
89
- [11.1.2 (2024-12-08)](#1112-2024-12-08)
910
- [11.1.1 (2024-11-26)](#1111-2024-11-26)
1011
- [11.1.0 (2024-11-17)](#1110-2024-11-17)
@@ -118,6 +119,11 @@ Change log
118119

119120
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
120121

122+
## 11.1.2-dev (TBD)
123+
* fix: [#2852](https://github.com/gridstack/gridstack.js/pull/2852) better React example. Thank you [CNine](https://github.com/Aysnine)
124+
* fix: [#2852](https://github.com/gridstack/gridstack.js/pull/2852) grid in tabs correctly handles CSS. Thank you [Luciano Martorella](https://github.com/lmartorella)
125+
* fix: [#2900](https://github.com/gridstack/gridstack.js/issues/2900) use attr `data-gs-widget` instead of `gridstacknode` (supported as well for backward compatibility)
126+
121127
## 11.1.2 (2024-12-08)
122128
* fix: [#2877](https://github.com/gridstack/gridstack.js/pull/2877) angular wrapper uses standalone, while now being compatible down to ng14. thanks to [andre-steudel](https://github.com/andre-steudel)
123129
* fix: [#2886](https://github.com/gridstack/gridstack.js/issues/2886) added `gs-size-to-content` support
@@ -129,8 +135,8 @@ Change log
129135

130136
## 11.1.0 (2024-11-17)
131137
* feat: [#2864](https://github.com/gridstack/gridstack.js/issues/2864) added `GridStackOptions.layout` for nested grid reflow during resize. default to 'list'.
132-
* fix: [#2859](https://github.com/gridstack/gridstack.js/pull/2859) re-enabled tests and fix numerous issues found (see CL). Also thank you [lmartorella](https://github.com/lmartorella) for getting me going and starting it.
133-
* fix: [#2851](https://github.com/gridstack/gridstack.js/pull/2851) added support for custom max layout saving - Thank you [lmartorella](https://github.com/lmartorella)
138+
* fix: [#2859](https://github.com/gridstack/gridstack.js/pull/2859) re-enabled tests and fix numerous issues found (see CL). Also thank you [Luciano Martorella](https://github.com/lmartorella) for getting me going and starting it.
139+
* fix: [#2851](https://github.com/gridstack/gridstack.js/pull/2851) added support for custom max layout saving - Thank you [Luciano Martorella](https://github.com/lmartorella)
134140
* fix: [#2492](https://github.com/gridstack/gridstack.js/issues/2492) loading same layout with overlapping widget fix. v10.3.0 regression.
135141

136142
## 11.0.1 (2024-10-21)

src/gridstack.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,12 +2200,14 @@ export class GridStack {
22002200

22012201
// sidebar items: load any element attributes if we don't have a node
22022202
if (!node) {
2203-
if (helper.hasAttribute('gridstacknode')) {
2203+
const attr = helper.getAttribute('data-gs-widget') || helper.getAttribute('gridstacknode'); // TBD: temp support for old V11.0.0 attribute
2204+
if (attr) {
22042205
try {
2205-
node = JSON.parse(helper.getAttribute('gridstacknode'));
2206+
node = JSON.parse(attr);
22062207
} catch (error) {
2207-
console.error("Gridstack dropover: Bad JSON format: ", helper.getAttribute('gridstacknode'));
2208+
console.error("Gridstack dropover: Bad JSON format: ", attr);
22082209
}
2210+
helper.removeAttribute('data-gs-widget');
22092211
helper.removeAttribute('gridstacknode');
22102212
}
22112213
if (!node) node = this._readAttr(helper); // used to pass false for #2354, but now we clone top level node

0 commit comments

Comments
 (0)