Skip to content

Commit 6f95488

Browse files
committed
a Map is enough (and more reliable), because there is only one projection for a given plot
1 parent b35d484 commit 6f95488

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/style.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,16 @@ function clipDefs({ownerSVGElement}) {
313313
}
314314

315315
// Note: may mutate selection.node!
316-
const frame = Symbol("frame");
317316
function applyClip(selection, mark, dimensions, context) {
318317
let clipUrl;
319318
const {clip = context.clip} = mark;
320319
switch (clip) {
321320
case "frame": {
322-
const clips = context.clips ?? (context.clips = new WeakMap());
323-
if (!clips.has(frame)) {
321+
const clips = context.clips ?? (context.clips = new Map());
322+
if (!clips.has("frame")) {
324323
const {width, height, marginLeft, marginRight, marginTop, marginBottom} = dimensions;
325324
const id = getClipId();
326-
clips.set(frame, id);
325+
clips.set("frame", id);
327326
clipDefs(context)
328327
.append("clipPath")
329328
.attr("id", id)
@@ -337,23 +336,23 @@ function applyClip(selection, mark, dimensions, context) {
337336
this.appendChild(selection.node());
338337
selection.node = () => this; // Note: mutation!
339338
});
340-
clipUrl = `url(#${clips.get(frame)})`;
339+
clipUrl = `url(#${clips.get("frame")})`;
341340
break;
342341
}
343342
case "sphere": {
344-
const clips = context.clips ?? (context.clips = new WeakMap());
343+
const clips = context.clips ?? (context.clips = new Map());
345344
const {projection} = context;
346345
if (!projection) throw new Error(`the "sphere" clip option requires a projection`);
347-
if (!clips.has(projection)) {
346+
if (!clips.has("projection")) {
348347
const id = getClipId();
349-
clips.set(projection, id);
348+
clips.set("projection", id);
350349
clipDefs(context)
351350
.append("clipPath")
352351
.attr("id", id)
353352
.append("path")
354353
.attr("d", geoPath(projection)({type: "Sphere"}));
355354
}
356-
clipUrl = `url(#${clips.get(projection)})`;
355+
clipUrl = `url(#${clips.get("projection")})`;
357356
break;
358357
}
359358
}

0 commit comments

Comments
 (0)