Skip to content

Commit

Permalink
add quick if statement to handle when options is not a defined element
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-martinwilson committed Oct 30, 2024
1 parent 5756053 commit 208d045
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/l-tile-layer-wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ class LTileLayerWMS extends LLayer {
const standardOptions = parse(schema, this);
const nonStandardOptionsElement = this.getAttribute("options");
const nonStandardOptions = () => {
try {
return JSON.parse(nonStandardOptionsElement);
} catch (e) {
console.error(
"Error whilst parsing JSON for options attribute in l-tile-layer-wms",
e,
);
return null;
if (nonStandardOptionsElement) {
try {
return JSON.parse(nonStandardOptionsElement);
} catch (e) {
console.error(
"Error whilst parsing JSON for options attribute in l-tile-layer-wms",
e,
);
return "";
}
} else {
return "";
}
};

Expand Down

0 comments on commit 208d045

Please sign in to comment.