Skip to content

Commit

Permalink
cursor plugin: fix element removal in destroy (#2462)
Browse files Browse the repository at this point in the history
* Change how elements are removed on destroying

When the plugin destroy() method was called, I got an error because removeChild was called with something that wasn't a Node, for this.showTime and this.cursor. 
It seems that these members are Proxy objects, and the removeChild doesn't swallow that. Changing from removeChild to remove() on the Proxy objects seems to fix this.

* Update CHANGES.md
  • Loading branch information
JanMisker committed Feb 28, 2022
1 parent e2c5e64 commit 709a4e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ wavesurfer.js changelog

6.0.3 (unreleased)
------------------

- Cursor plugin:
- Fix type documentation for `followCursorY` and `opacity` options (#2459)
- Fix destroying cursor and showTime dom nodes (#2460)

6.0.2 (20.02.2022)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/cursor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ export default class CursorPlugin {
*/
destroy() {
if (this.params.showTime) {
this.cursor.parentNode.removeChild(this.showTime);
this.showTime.remove();
}
this.cursor.parentNode.removeChild(this.cursor);
this.cursor.remove();
this.wrapper.removeEventListener('mousemove', this._onMousemove);
if (this.params.hideOnBlur) {
this.wrapper.removeEventListener('mouseenter', this._onMouseenter);
Expand Down

0 comments on commit 709a4e0

Please sign in to comment.