Skip to content

Commit

Permalink
Merge pull request #568 from 3DStreet/dont-save-autocreated
Browse files Browse the repository at this point in the history
dont save entities with "autocreated" class
  • Loading branch information
kfarr authored Jun 10, 2024
2 parents 22b8894 + e44ee88 commit fc5ed28
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/json-utils_1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,22 @@ 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
const skipChildrenNodes = ['environment', 'reference-layers'];
const skipChildrenNodes = ['environment'];
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.length > 0) elementTree['children'] = savedChildren;
}
return elementTree;
}
Expand Down

0 comments on commit fc5ed28

Please sign in to comment.