Raises an exception if the component is destroyed before it initializes.
kitsunde opened this issue · 2 comments
Because of the async nature of the initialization it's possible for someone to have removed the component that's being initialized raising:
Couldn't find the iframe element to create a YouTube player
This is very evident on mobile browsers for us where we have the player in a modal that can be closed and removed. The cause is here: https://github.com/oskarrough/ember-youtube/blob/master/addon/components/ember-youtube.js#L133
This in turn ends up getting logged as an error since the exception is raised all the way to the global exception logger, but it isn't really since the user has intentionally removed the element. I think there should be a check to see if the component has been destroyed or not.
Thank you very much for reporting. Unfortunately I'm having quite a few issues with the async initialization. Any ideas where to put that check?
I tried toggling an ember-youtube component in a template but couldn't get the error to throw. Are you using the lazyload option on the component in the modal?
See #33 as well.
I've been trying to make it fail in this branch https://github.com/oskarrough/ember-youtube/tree/test-destroyed-component