tryggvigy / pseudo-localization

Dynamic pseudo-localization in the browser and nodejs
https://tryggvigy.github.io/pseudo-localization/hamlet.html
MIT License
140 stars 15 forks source link

Crashes for (certain) childList mutations due to incorrect options being forwarded to pseudoLocalize #11

Closed jopdeklein closed 5 years ago

jopdeklein commented 5 years ago

Thanks for this project Tryggvi!

Trying this on an existing project works fine if I run start() after the DOM is fully done rendering, but throws an exception during certain childList mutations. The pseudoLocation function is called with wrong options (it get's called with 0 in my case) in this line: https://github.com/tryggvigy/pseudo-localization/blob/master/index.js#L46

I haven't quite figured out what exactly is triggering the issue yet, but I was able to fix it by inverting the options and partially applying it with the correct options to forwarding to the addedNode.forEach to avoid excess parameters messing up the options argument.

I will create a PR with the safeguards which work for my project (I also seem to need #6 ), and try to figure out why it fails in the first place.

tryggvigy commented 5 years ago

Hey @jopdeklein, thanks for filing the issues and the PR. I'll take a look at them all as soon as I have some free time!