shobhitsharma / embedo

Embeds third party content to DOM with perks 🧙‍♀️ (7kb gzip / standalone)
https://shobhitsharma.github.io/embedo
MIT License
347 stars 32 forks source link

Error in pinterest handler #11

Closed nborko closed 6 years ago

nborko commented 6 years ago

If the pinistrify function, handlePinterestEmbed makes this check:

https://github.com/shobhitsharma/embedo/blob/46c7821397088d3e0c6e956ed3e0e562223938eb/embedo.js#L1593

pinterest_embed_timer is an interval ID, so you'll always get an error, even if the embed is successful, if the ID pool is over 100 (pretty common, especially in SPA).

I'm not sure what this is supposed to be checking, but even if you use a counter here instead, 100 * 250ms (25 seconds) seems too long. Something like 20, or 5s total, would be more reasonable.

Also, I'm reasonably certain that the setInterval call here:

https://github.com/shobhitsharma/embedo/blob/46c7821397088d3e0c6e956ed3e0e562223938eb/embedo.js#L1578

should be inside the setTimeout after the if block containing the PinUtils.build call:

https://github.com/shobhitsharma/embedo/blob/46c7821397088d3e0c6e956ed3e0e562223938eb/embedo.js#L1580-L1584

(after line 1583)

My changes here https://github.com/nborko/embedo/blob/865fcbe1da62467a333d31838541c39861294c48/embedo.js#L1578-L1598 work for me, please let me know if you'd like a PR.

thanks, Nick

shobhitsharma commented 6 years ago

@nborko Hi Nick, thanks for the issue and PR mate. I checked and merged it. Looks fine now.