JuliaLang / www_old.julialang.org

Julia Project web site (Old)
http://www_old.julialang.org/
Other
150 stars 276 forks source link

Fix wrong id for transifex widget. #687

Closed Ismael-VC closed 6 years ago

Ismael-VC commented 6 years ago

Fixes:

Uncaught TypeError: Cannot read property 'appendChild' of null
    at (index):1072
waldyrious commented 6 years ago

Did you successfully test this? If I try it, it adds the link to the menu header, rather than as an entry in the list of languages.

I'm pretty sure the "tx-live-lang-picker" ID is the right one, but the script must wait until it is created dynamically before it runs. I'll see if I can introduce some sort of listener. I think we'll need to use the Mutation Observer API. I'll comment when I have more info.

waldyrious commented 6 years ago

After some time reading about Mutation Observers. More than I would have liked, actually -- I ended up modifying the MDN example because, like everything else I was finding online, it included unnecessary complexity that made the basic concept harder to grasp.

Anyway, it looks like a possible way to fix this, although quite verbose (it will pretty much double the size of this script). I'll submit a PR with the proposed fix; hopefully it'll work out.