Skip to content

Commit

Permalink
fix condition syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Dec 18, 2024
1 parent c934bf1 commit 0d94d49
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/layer/styleParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,24 @@ export default function styleParser(layer) {
// Assign the first key from themes object as theme string property if undefined.
layer.style.theme ??= Object.keys(layer.style.themes)[0]

// Assign theme object from themes object if not already an object.
layer.style.theme = typeof layer.style.theme === 'object'
? layer.style.theme
: layer.style.themes[layer.style.theme];
// Assign theme property from themes object if string.
if (typeof layer.style.theme === 'string') {

layer.style.theme = layer.style.themes[layer.style.theme]
}
}

// Handle multiple hovers in layer style.
if (layer.style?.hovers) {

// Assign the first key from hovers object as hover string property if undefined.
layer.style.hover ??= Object.keys(layer.style.hovers)[0]

// Assign hover object from hovers object if not already an object.
typeof layer.style.hover === 'object'
? layer.style.hover
: layer.style.hovers[layer.style.hover];

// Assign hover property from hovers object if string.
if (typeof layer.style.hover === 'string') {

layer.style.hover = layer.style.hovers[layer.style.hover]
}
}

// Set default featureHover method if not provided.
Expand All @@ -130,11 +132,13 @@ export default function styleParser(layer) {

// Assign the first key from labels object as label string property if undefined.
layer.style.label ??= Object.keys(layer.style.labels)[0]

// Assign label object from labels object if not already an object.
layer.style.label = typeof layer.style.label === 'object'
? layer.style.label
: layer.style.labels[layer.style.label];


// Assign label property from labels object if string.
if (typeof layer.style.label === 'string') {

layer.style.label = layer.style.labels[layer.style.label]
}
}
}

Expand Down

0 comments on commit 0d94d49

Please sign in to comment.