e.target.className.indexOf is undefined if target is svg element
See original GitHub issueI needed to change line #L447 (https://github.com/isteven/angular-multi-select/blob/master/angular-multi-select.js#L447) because clicking on a svg element was not working as expected.
if ( e.target.className.indexOf === undefined || e.target.className.indexOf( 'multiSelect' ) === -1 ) {
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to get indexOf proper className of targeted element?
I have an target element which is a SVG which has two properties baseVal and aniVal , So I'm trying to get the...
Read more >TypeError: el.className.indexOf is not a function
I have link inside svg element. When i click on this element i have error “TypeError: el.className.indexOf is not a function” (o forms.js:23) ......
Read more >a[b].target.className.indexOf is not a function, at least not mine
I take a look in our TrackJS console and I see that the PayPal checkout integration button is throwing an error that it...
Read more >Element.className - Web APIs | MDN
The className property of the Element interface gets and sets the value of the class attribute of the specified element.
Read more >target Event Property - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same issue with ‘use’ tags that we use inside ‘svg’ tags. To fix this error you can extend SVGAnimatedString prototype (as this is a type that className property returns in this case - apparently it does not have indexOf method, hence the unhandled exception), like this:
Once you drop this inside root directory of your app, the issue will be resolved as now your ‘use’ tags (or any other tag that returns type SVGAnimatedString type, rather then string, for className property of the node element) will have indexOf method.
In my case adding ‘notranslate’ to each svg was not best solution as on the page there was a lot of svgs added at different times by different components.
Hope it will help someone out there as well.
@sandun86 Thanks.