Skip to content

Commit

Permalink
fix export of visible false
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentfretin committed Sep 1, 2024
1 parent 22bca26 commit 95ada94
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/json-utils_1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ function getAttributes(entity) {
elemObj['components'] = {};
for (const componentName in entityComponents) {
const modifiedProperty = getModifiedProperty(entity, componentName);
if (modifiedProperty) {
if (isEmpty(modifiedProperty)) {
if (modifiedProperty !== null) {
if (isEmptyObject(modifiedProperty)) {
elemObj['components'][componentName] = '';
} else {
elemObj['components'][componentName] = toPropString(modifiedProperty);
Expand Down Expand Up @@ -168,8 +168,13 @@ function isSingleProperty(schema) {
return AFRAME.schema.isSingleProperty(schema);
}

function isEmpty(object) {
return Object.keys(object).length === 0;
function isEmptyObject(object) {
return (
typeof object === 'object' &&
!Array.isArray(object) &&
object !== null &&
Object.keys(object).length === 0
);
}

// a list of component:value pairs to exclude from the JSON string.
Expand Down Expand Up @@ -201,7 +206,7 @@ function filterJSONstreet(streetJSON) {
compAttributes = AFRAME.utils.styleParser.parse(value);
const removeVal = removeProps[removeKey];
// check for deleting component's attribute
if (typeof removeVal === 'object' && !isEmpty(removeVal)) {
if (!isEmptyObject(removeVal)) {
// remove attribute in component
const attrNames = Object.keys(removeVal);
for (var attrName of attrNames) {
Expand Down

0 comments on commit 95ada94

Please sign in to comment.