Skip to content

Commit 0337a8f

Browse files
committed
nested grid save inf loop fix
fix #1860 which was caused by #1793 * cloneDeep() will now skip clonning internal known objects we don't serialize (and delete later with removeInternalAndSame())
1 parent 95c91e2 commit 0337a8f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/CHANGES.md

Lines changed: 4 additions & 0 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+
- [4.2.7-dev (TBD)](#427-dev-tbd)
89
- [4.2.7 (2021-9-12)](#427-2021-9-12)
910
- [4.2.6 (2021-7-11)](#426-2021-7-11)
1011
- [4.2.5 (2021-5-31)](#425-2021-5-31)
@@ -61,6 +62,9 @@ Change log
6162

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

65+
## 4.2.7-dev (TBD)
66+
* fix [#1860](https://github.com/gridstack/gridstack.js/issues/1860) nested grid save inf loop fix
67+
6468
## 4.2.7 (2021-9-12)
6569

6670
* fix [#1817](https://github.com/gridstack/gridstack.js/issues/1817) Enable passing of DragEvent to gridstack dropped event. Thanks [@onepartsam](https://github.com/onepartsam)

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,13 @@ export class Utils {
393393
const ret = Utils.clone(obj);
394394
for (const key in ret) {
395395
// NOTE: we don't support function/circular dependencies so skip those properties for now...
396-
if (ret.hasOwnProperty(key) && typeof(ret[key]) === 'object' && key.substring(0, 2) !== '__') {
396+
if (ret.hasOwnProperty(key) && typeof(ret[key]) === 'object' && key.substring(0, 2) !== '__' && !skipFields.find(k => k === key)) {
397397
ret[key] = Utils.cloneDeep(obj[key]);
398398
}
399399
}
400400
return ret;
401401
}
402402
}
403403

404+
// list of fields we will skip during cloneDeep (nested objects, other internal)
405+
const skipFields = ['_isNested', 'el', 'grid', 'subGrid', 'engine'];

0 commit comments

Comments
 (0)