Skip to content

Commit 591e740

Browse files
committed
Fix compatibility with Edge and bug in state init
Edge doesn't have path2d.addPath() Checkbox state init didn't handle reading null from storage well
1 parent 341cda4 commit 591e740

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

InteractiveHtmlBom/web/ibom.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ function getStoredCheckboxRefs(checkbox) {
104104
}
105105
}
106106
if (!(checkbox in settings.checkboxStoredRefs)) {
107-
settings.checkboxStoredRefs[checkbox] = readStorage("checkbox_" + checkbox);
107+
var val = readStorage("checkbox_" + checkbox);
108+
settings.checkboxStoredRefs[checkbox] = val ? val : "";
108109
}
109110
if (!settings.checkboxStoredRefs[checkbox]) {
110111
return new Set();
111112
} else {
112-
return new Set(settings.checkboxStoredRefs[checkbox].split(",").map(r => convert(r)));
113+
return new Set(settings.checkboxStoredRefs[checkbox].split(",").map(r => convert(r)).filter(a => a >= 0));
113114
}
114115
}
115116

InteractiveHtmlBom/web/render.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,15 @@ function getPolygonsPath(shape) {
177177
if (shape.svgpath) {
178178
shape.path2d = new Path2D(shape.svgpath);
179179
} else {
180-
var combinedPath = new Path2D();
180+
var path = new Path2D();
181181
for (var polygon of shape.polygons) {
182-
var path = new Path2D();
183-
for (var vertex of polygon) {
184-
path.lineTo(...vertex)
182+
path.moveTo(...polygon[0]);
183+
for (var i = 1; i < polygon.length; i++) {
184+
path.lineTo(...polygon[i]);
185185
}
186186
path.closePath();
187-
combinedPath.addPath(path);
188187
}
189-
shape.path2d = combinedPath;
188+
shape.path2d = path;
190189
}
191190
return shape.path2d;
192191
}

0 commit comments

Comments
 (0)