lottie-web: Lottie causing problems with Google Translate
Tell us about your environment Mac 2015 Retina Display
Browser and Browser Version: Chrome v.67
Problem My animations were working great on the website! I decided to add Google Translate and ended up getting hundreds of errors every second. I discovered by deduction that this was because of my Lottie animations. My HTML looks like this for the animation:
<div id="choosing" class="cardAnim"></div>
and the js :
var animation2 = bodymovin.loadAnimation({ container: document.getElementById('choosing'), renderer: 'svg', loop: true, autoplay: true, path: '/img/choosing/data.json', assetsPath: '' })
.
Anyways, the error Google translate is giving me from Lottie is :
element_main.js:405 Uncaught TypeError: a[b].target.className.indexOf is not a function at au.v.Ai (element_main.js:405)
Thanks in advance!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 15
The issue continues to live. It is almost 2020 đ The cause is the âGoogle Website Translatorâ embedded into Chrome now (not as an extension as it was earlier). When you try to open any non-native language page in Chrome itâs âTranslatorâ starts to parse nodes on the page and checks itâs className in a straight way:
it checks only the existence of className and executes indexOf right after it. But for
SVGElement
the className is an instance ofSVGAnimatedString
which doesnât have#indexOf()
.I tried
meta[name="google"][content="notranlate"]
, I triedclass="notranslate"
. Often it doesnât help. Especially with lazy-loaded SVGs (we have react + lottie + lazy loaded svg-jsons).I tried to declare
SVGAnimatedString.prototype.indexOf
at the top of the page. But seems like Translator works in its own sandbox or not sure, didnât investigate.We were forced to switch off Sentry error tracker cause of the frequency of this error and exceeding our budget without profit. Especially when there is animation and exceptions are generated infinitely.
Some of the stackoverflow answers tell âturn off translator inside browser propertiesâ. Aha. Inside the clientâs browser. Give me just a secâŚ
Researching for a solution.
We had the same issue, i wrote in details about it here: https://medium.com/@amir.harel/a-b-target-classname-indexof-is-not-a-function-at-least-not-mine-8e52f7be64ca