Yep you are right... I added this check because of ```wavesurfer.drawer.clearSelection(mark0, mark1)``` calling ```drawer.canvas.eraseSelectionMarks(mark0, mark1)``` finally calling ```drawer.canvas.removeMark(mark)``` even if mark is undefined... which is firing a js error...

Ìf you agrre with that, I can do either : 

- in ```wavesurfer.clearSelection```

```
if (this.selMark0 && this.selMark1) {
    this.drawer.clearSelection(this.selMark0, this.selMark1);
}
```

- in drawer.clearSelection

```
if(mark0 && mark1)
    this.eraseSelectionMarks(mark0, mark1);
```

- in drawer.canvas.eraseSelectionMarks

 ```
if(mark0)
    this.removeMark(mark0);
if(mark1)
    this.removeMark(mark1);
```

- in drawer.canvas.removeMark

 ```
if (mark) {
    var markEl = document.getElementById(mark.id);
    if (markEl) {
        this.wrapper.removeChild(markEl);
    }
}
```

...or leave it like it is