From 0f79111e84efc9ff69de78598738aa6bbba8546e Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin <aleotu@gmail.com> Date: Fri, 7 Jun 2024 14:27:15 -0400 Subject: [PATCH 1/2] dont save entities with "autocreated" class --- src/json-utils_1.1.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/json-utils_1.1.js b/src/json-utils_1.1.js index f58eeed52..84a7a5ddc 100644 --- a/src/json-utils_1.1.js +++ b/src/json-utils_1.1.js @@ -65,7 +65,7 @@ function convertDOMElToObject(entity) { STREET.utils.convertDOMElToObject = convertDOMElToObject; function getElementData(entity) { - if (!entity.isEntity) { + if (!entity.isEntity || entity.classList.contains('autocreated')) { return; } // node id's that should save without child nodes @@ -73,12 +73,14 @@ function getElementData(entity) { const elementTree = getAttributes(entity); const children = entity.childNodes; if (children.length && !skipChildrenNodes.includes(elementTree.id)) { - elementTree['children'] = []; + const savedChildren = []; for (const child of children) { if (child.nodeType === Node.ELEMENT_NODE) { - elementTree['children'].push(getElementData(child)); + const elementData = getElementData(child); + if (elementData) savedChildren.push(elementData); } } + if (savedChildren) elementTree['children'] = savedChildren; } return elementTree; } From e44ee8834381ccf0e14485e8ee53d2fc3a4005b6 Mon Sep 17 00:00:00 2001 From: Kieran Farr <kieran.farr@gmail.com> Date: Mon, 10 Jun 2024 09:38:16 -0700 Subject: [PATCH 2/2] fix saveChildren length logic also remove reference layers from skip children node - instead @Algorush we will need to ensure that all children layers have "autocreated" class instead of skipping then in skipchildrennode --- src/json-utils_1.1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json-utils_1.1.js b/src/json-utils_1.1.js index 84a7a5ddc..1d9828dfc 100644 --- a/src/json-utils_1.1.js +++ b/src/json-utils_1.1.js @@ -69,7 +69,7 @@ function getElementData(entity) { return; } // node id's that should save without child nodes - const skipChildrenNodes = ['environment', 'reference-layers']; + const skipChildrenNodes = ['environment']; const elementTree = getAttributes(entity); const children = entity.childNodes; if (children.length && !skipChildrenNodes.includes(elementTree.id)) { @@ -80,7 +80,7 @@ function getElementData(entity) { if (elementData) savedChildren.push(elementData); } } - if (savedChildren) elementTree['children'] = savedChildren; + if (savedChildren.length > 0) elementTree['children'] = savedChildren; } return elementTree; }