Guard against JSON.parse errors.
Also show successful style parse status after a style error was corrected but it is the same style as previously.
This commit is contained in:
@@ -81,13 +81,12 @@ function setStyleStatus(valid) {
|
|||||||
const editor = document.getElementById('style-editor');
|
const editor = document.getElementById('style-editor');
|
||||||
editor.addEventListener('input', function() {
|
editor.addEventListener('input', function() {
|
||||||
const textStyle = editor.value;
|
const textStyle = editor.value;
|
||||||
if (JSON.stringify(JSON.parse(textStyle)) === JSON.stringify(literalStyle)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
literalStyle = JSON.parse(textStyle);
|
const newLiteralStyle = JSON.parse(textStyle);
|
||||||
refreshLayer();
|
if (JSON.stringify(newLiteralStyle) !== JSON.stringify(literalStyle)) {
|
||||||
|
literalStyle = newLiteralStyle;
|
||||||
|
refreshLayer();
|
||||||
|
}
|
||||||
setStyleStatus(true);
|
setStyleStatus(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setStyleStatus(false);
|
setStyleStatus(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user