Skip to content

Commit b186f24

Browse files
committed
SSR temp workaround
tweak to #2596
1 parent 88c99d3 commit b186f24

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Change log
112112
* fix: [#2577](https://github.com/gridstack/gridstack.js/issues/2577) ui-resizable-s/-n style fix
113113
* fix: [#2576](https://github.com/gridstack/gridstack.js/issues/2576) column('none') now ignores layouts
114114
* fix: [#2560](https://github.com/gridstack/gridstack.js/issues/2560) nested grid fix (enter can call leave which can call enter again) - Thank you [v1talii-dev](https://github.com/v1talii-dev)
115+
* fix: [#2596](https://github.com/gridstack/gridstack.js/pull/2596) prevent SSR crash
115116
* doc: nested.htm now has nested create and drag&drop example - Thank you [fredericrous](https://github.com/fredericrous)
116117

117118
## 10.0.1 (2023-12-10)

src/gridstack.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ export class GridStack {
9494
* let grid = document.querySelector('.grid-stack').gridstack;
9595
*/
9696
public static init(options: GridStackOptions = {}, elOrString: GridStackElement = '.grid-stack'): GridStack {
97-
if(typeof document === 'undefined') {
98-
return null
99-
}
97+
if (typeof document === 'undefined') return null; // temp workaround SSR
10098
let el = GridStack.getGridElement(elOrString);
10199
if (!el) {
102100
if (typeof elOrString === 'string') {
@@ -124,9 +122,7 @@ export class GridStack {
124122
*/
125123
public static initAll(options: GridStackOptions = {}, selector = '.grid-stack'): GridStack[] {
126124
let grids: GridStack[] = [];
127-
if(typeof document === 'undefined') {
128-
return grids
129-
}
125+
if (typeof document === 'undefined') return grids; // temp workaround SSR
130126
GridStack.getGridElements(selector).forEach(el => {
131127
if (!el.gridstack) {
132128
el.gridstack = new GridStack(el, Utils.cloneDeep(options));

0 commit comments

Comments
 (0)