keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
372 stars 102 forks source link

bug(web): `TypeError: p.className.indexOf is not a function` #11364

Closed sentry-io[bot] closed 1 week ago

sentry-io[bot] commented 1 week ago

Sentry Issue: KEYMAN-DEVELOPER-1SN

TypeError: p.className.indexOf is not a function
  at this.touchStartActivationHandler (@keymanapp/keyman/web/src/app/browser/src/context/pageIntegrationHandlers.ts:125:24)
mcdurdin commented 1 week ago

This looks like a bug in Web where element.className may be null. I have seen before where element.className is null or undefined, even though MDN doesn't spec this AFAICT.

https://github.com/keymanapp/keyman/blob/93d4e60e6359888783566dc855a8a5fe6c756e4f/web/src/app/browser/src/context/pageIntegrationHandlers.ts#L125

mcdurdin commented 1 week ago

OK, found it! It is because the user touches an SVG element on the page:

className can also be an instance of SVGAnimatedString if the element is an SVGElement.

In the Keyman Developer test window, the hamburger menu icon is an SVG element. Touching that is enough to trigger this error. We should test the property type before attempting to call string functions on it, or wrap it.