mirror of
https://github.com/motajs/template.git
synced 2026-11-25 07:24:30 +08:00
test(event): polyfill map insertion in fixtures
This commit is contained in:
1 parent
63d4d37ff3
commit
33966fb4dd
4 files changed
+37
-14
No files matched your search
@@ -213,20 +213,10 @@ export class MapLayer
|
||||
event(x: number, y: number): ILayerEventView | null {
|
||||
if (!this.inMap(x, y)) return null;
|
||||
const index = y * this.width + x;
|
||||
const getOrInsertComputed = this.pointEvents.getOrInsertComputed;
|
||||
if (getOrInsertComputed) {
|
||||
return getOrInsertComputed.call(
|
||||
this.pointEvents,
|
||||
index,
|
||||
() => new LayerEventView()
|
||||
);
|
||||
}
|
||||
let eventView = this.pointEvents.get(index);
|
||||
if (!eventView) {
|
||||
eventView = new LayerEventView();
|
||||
this.pointEvents.set(index, eventView);
|
||||
}
|
||||
return eventView;
|
||||
return this.pointEvents.getOrInsertComputed(
|
||||
index,
|
||||
() => new LayerEventView()
|
||||
);
|
||||
}
|
||||
|
||||
getPointEvent(x: number, y: number): ReadonlyMap<number, string> | null {
|
||||
|
||||
Reference in new issue
Block a user