Skip to content

Commit

Permalink
Merge pull request #355 from 3DStreet/dont-save-JSON-property
Browse files Browse the repository at this point in the history
dont save street propery in JSON
  • Loading branch information
kfarr authored Oct 30, 2023
2 parents 348b008 + 8fced24 commit 016c5f1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/json-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const removeProps = {
normalMap: {},
'set-loader-from-hash': '*',
'create-from-json': '*',
street: { JSON: '*' }
street: {JSON: '*'}
};
// a list of component_name:new_component_name pairs to rename in JSON string
const renameProps = {
Expand All @@ -184,25 +184,26 @@ function filterJSONstreet(removeProps, renameProps, streetJSON) {
}

let stringJSON = JSON.stringify(streetJSON, function replacer(key, value) {
const compAttributes = AFRAME.utils.styleParser.parse(value);
for (var removeKey in removeProps) {
// check for removing components
if (key === removeKey) {
const removeVal = removeProps[removeKey];
// check for deleting component's attribute
if (typeof removeVal === 'object' && !isEmpty(removeVal)) {
// remove attribute in component
const compAttributes = value;

// remove attribute in component
const attrNames = Object.keys(removeVal);
for (var attrName of attrNames) {
const attrVal = removeVal[attrName];
if (
Object.prototype.hasOwnProperty.call(compAttributes, attrName) &&
removeValueCheck(attrVal, compAttributes[attrName])
) {
delete value[attrName];
delete compAttributes[attrName];
}
}

}
// for other cases
if (removeValueCheck(removeVal, value)) {
Expand All @@ -211,7 +212,7 @@ function filterJSONstreet(removeProps, renameProps, streetJSON) {
}
}

return value;
return compAttributes;
});
// rename components
for (var renameKey in renameProps) {
Expand Down

0 comments on commit 016c5f1

Please sign in to comment.