polimediaupv / paella-core

Paella Player core library
Educational Community License v2.0
20 stars 15 forks source link

Fix bug in `loadStyle` and add `destroy` method for cleanup #353

Closed LukasKalbertodt closed 7 months ago

LukasKalbertodt commented 7 months ago

Hi there!

In Tobira we noticed that unloading a Paella instance and loading a new one caused some console errors and other weird behavior. This PR tries to address some of that. The first commit adds a destroy method which does a complete cleanup. This is very useful for SPAs like Tobira, where Paella instances are created and destroyed again, and that shouldn't leave any traces. Without this destroy method, certain event handlers and other global values still exist. The destroy method fixes that.

The second commit is a simple bug fix where a promise sometimes returned undefined (by calling resolve() without arguments). That undefined value is later passed to a function that throws an error. You can see that on tobira.opencast.org when clicking on one video and then on a second one.

I hope these changes are ok like this!