From 662e4240ec8475eb9c3cb7a1d795070208b1adb8 Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Sat, 1 Jun 2024 20:51:00 +0200 Subject: [PATCH] feat(Selection): don't implicitly selectAll when calling apply or copy without selection --- src/Selection.ts | 76 ------------------------------------------------ 1 file changed, 76 deletions(-) diff --git a/src/Selection.ts b/src/Selection.ts index 93e764e0..45aa4ddb 100644 --- a/src/Selection.ts +++ b/src/Selection.ts @@ -110,21 +110,11 @@ export abstract class Selection> { } apply(fn: (item: T[0], idx: number) => void) { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - this.selection.forEach((idx) => { const item = this.items[idx] fn(item, idx) }) - if (applyToAll) { - this.clearSelection() - } - return this } @@ -135,18 +125,7 @@ export abstract class Selection> { export class PolygonSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new PolygonSelection(new Polygons(...copiedItems)) as this } @@ -208,18 +187,7 @@ export class PolygonSelection extends Selection { export class LightsSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new LightsSelection(new Lights(...copiedItems)) as this } @@ -232,18 +200,7 @@ export class LightsSelection extends Selection { export class EntitiesSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new EntitiesSelection(new Entities(...copiedItems)) as this } @@ -256,18 +213,7 @@ export class EntitiesSelection extends Selection { export class FogsSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new FogsSelection(new Fogs(...copiedItems)) as this } @@ -280,18 +226,7 @@ export class FogsSelection extends Selection { export class PathsSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new PathsSelection(new Paths(...copiedItems)) as this } @@ -304,18 +239,7 @@ export class PathsSelection extends Selection { export class ZonesSelection extends Selection { copy() { - const applyToAll = !this.hasSelection() - - if (applyToAll) { - this.selectAll() - } - const copiedItems = this.selection.map((idx) => this.items[idx].clone()) - - if (applyToAll) { - this.clearSelection() - } - return new ZonesSelection(new Zones(...copiedItems)) as this }