Closed imsus closed 8 years ago
I'm so glad you've reported this 👍
This bug is really interesting. I've found the problem:
We have been using document.addEventListener('DOMContentLoaded', callback)
to ensure the data-attributes are on the page before openshare runs. However, with <script async ...
openshare is actually being parsed after the DOM loads, which means openshare is missing the DOMContentLoaded event and never runs.
What we ought to do instead (or additionally) is check for document.readyState. This is what jQuery(document).ready() does. Or, alternatively, use document.onreadystatechange.
If you want to take on the initiative to send a pull request I'd be glad to see it through and answer any questions along the way!
Otherwise, I'll try my best to fix this soon.
Thank you @imsus 🎉
I would like to work on it.
Merged the fix from @matteo-hertel and published it to npm
@imsus you should be able use the cdn reference in this demo until the cache on cdn.rawgit.com refreshes
thank you so much everyone 😄
Using data-attributes and initiate with async scripts. Demo
Because no console error logs. It's hard to track.