setProperty function doesn't set an empty array if property doesn't exist

This commit is contained in:
GRL 2021-07-02 14:40:18 +02:00
parent e1611969ce
commit c5b5326480
3 changed files with 5 additions and 8 deletions

View file

@ -1075,11 +1075,13 @@ ${escapedMessage}
console.warn('Could not find layer "' + layerName + '" when calling setProperty');
return;
}
const property = (layer.properties as ITiledMapLayerProperty[])?.find(
if (layer.properties === undefined) {
layer.properties = [];
}
const property = (layer.properties as ITiledMapLayerProperty[]).find(
(property) => property.name === propertyName
);
if (property === undefined) {
layer.properties = [];
layer.properties.push({ name: propertyName, type: typeof propertyValue, value: propertyValue });
return;
}