Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): support SVG elements when checking className #11365

Merged
merged 1 commit into from
May 7, 2024

Conversation

mcdurdin
Copy link
Member

@mcdurdin mcdurdin commented May 6, 2024

Fixes #11364.

Instead of using className which may be of type SVGAnimatedString if the element is an SVG element, use getAttribute('class'). As that function can return null if the class attribute is not defined, use optional chaining to avoid a new error...

Uses the same pattern in hardwareEventKeyboard.ts, although I suspect the problem may never arise there.

I audited the uses of className in our KeymanWeb source and found only these three instances which may be problematic. I have not searched elsewhere.

@keymanapp-test-bot skip

Fixes #11364.

Instead of using `className` which may be of type `SVGAnimatedString` if
the element is an SVG element, use `getAttribute('class')`. As that
function can return `null` if the class attribute is not defined, use
optional chaining to avoid a new error...

Uses the same pattern in hardwareEventKeyboard.ts, although I suspect
the problem may never arise there.

I audited the uses of className in our KeymanWeb source and found only
these three instances which may be problematic. I have not searched
elsewhere.
@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S1 milestone May 6, 2024
@darcywong00 darcywong00 linked an issue May 6, 2024 that may be closed by this pull request
@mcdurdin mcdurdin merged commit a1668d4 into beta May 7, 2024
16 checks passed
@mcdurdin mcdurdin deleted the fix/web/11364-className-svg branch May 7, 2024 03:58
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.320-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

bug(web): TypeError: p.className.indexOf is not a function
4 participants