openaustralia / theyvoteforyou

Making parliamentary voting information accessible, understandable, and easy to use so that you can hold your elected representatives to account.
https://theyvoteforyou.org.au/
Other
135 stars 30 forks source link

Changed `DOMContentLoaded` to `load` in all eventlisteners for all social media cards #1389

Closed MutazAshhab closed 2 years ago

MutazAshhab commented 2 years ago

Fixes issue #1388

Changes all event listeners to fire off on load rather than on DOMContentLoaded

mlandauer commented 2 years ago

@Taz17 have you tested how this change interacts with the screenshot code? My first thought is if the javascript runs later is there now a possibility that the screenshot will get taken before the javascript has run?

I guess it's a question of testing and understanding at what point exactly the screenshot happens.

MutazAshhab commented 2 years ago

I am trying to test this out... Google chrome updated to version 100.xx and now the gem is not working. Im trying to fix this issue now.

mlandauer commented 2 years ago

I am trying to test this out... Google chrome updated to version 100.xx and now the gem is not working. Im trying to fix this issue now.

I don't think you need to downgrade google chrome. You can upgrade the chrome driver instead. That should be simpler.

MutazAshhab commented 2 years ago

@mlandauer The screenshots come out just fine as they should. The JavaScript is being executed before the screenshot is taken.

The difference between the DOMContentLoaded and load event listeners is that DOMContentLoaded does not wait for images or stylesheets. So the javascript executes before everything is positioned and font size is set hence causing the card to render the way it did as the screenshot I posted in the issue.

Using the load event listener means the text will shrink once styling and images are rendered. Hence avoiding that render I posted