paulirish / lite-youtube-embed

A faster youtube embed.
https://paulirish.github.io/lite-youtube-embed/
Other
5.84k stars 271 forks source link

Fix duplicate iframes being created #97

Closed codepuncher closed 2 years ago

codepuncher commented 2 years ago

Fixes #92

paulirish commented 2 years ago

@codepuncher thanks for hacking on this

also wow i really did not think this worked but.. turns out context doesnt work the way i thought it did. but yeah this is bueno.

Side note: as long as your event handler is a method of your custom element, there is no need to manually bind it. When calling addEventListener, the value of this inside the event handler is a reference to the element.

via https://open-wc.org/guides/knowledge/events/#on-your-elements

do you have an idea on why this fixes the duplicate iframe behavior?

paulirish commented 2 years ago

I added a lil dirty check here as well, just to toughen things up.

codepuncher commented 2 years ago

do you have an idea on why this fixes the duplicate iframe behavior?

Honestly, no. But I wish I did!

Thanks for merging.