taataa / tapspace

Zoomable user interface library for web apps.
https://taataa.github.io/tapspace/
MIT License
58 stars 8 forks source link

allow removal of missing Viewport controls #178

Open axelpale opened 7 months ago

axelpale commented 7 months ago

If the client tries to remove a Control that is not yet added to a viewport, currently that throws an error. Maybe such removal should be okay and silent. Think of the removal as an idempotent operation. Is addition already an idempotent operation if the component is already added to the same parent?

axelpale commented 7 months ago

It does not help either that Viewport does not implement any "hasControl" method nor Component any "hasChild" method.

axelpale commented 7 months ago

Current workaround is:

try {
  viewport.removeControl(alreadyRemovedControl)
} catch (e) {
  // noop
}