nagvis icon indicating copy to clipboard operation
nagvis copied to clipboard

SVG Gadget - Javascript error occured: Uncaught TypeError: o.className.split is not a function

Open itsul opened this issue 4 years ago • 1 comments

Currently there is a problem with the referenced hasClass function. When a svg-Element is queried it doesn't return a string as a classname. Moreover it is a object of type SVGAnimatedString and handles classes differently to "normal" HTML-elements.

Problematic line: https://github.com/NagVis/nagvis/blob/16732d5cbc4ee73e83292854a2968d9c6e720d43/share/frontend/nagvis-js/js/nagvis.js#L1402

Others found a solution: https://github.com/ionic-team/ionic-service-analytics/issues/34#issuecomment-160252242

The issue appears as a popup within NagVis and contains following message: Javascript error occured: Uncaught TypeError: o.className.split is not a function https://system/nagvis/frontend/nagvis-js/js/NagVisCompressed.js?v=1.9.11 (862)

Using following line fixes the issue for me: var parts=('' + o.className).split(' '); instead of: var parts=o.className.split(' ');

itsul avatar Dec 04 '19 06:12 itsul

That sounds to me like o.classname isn't defined or o isn't. By adding '', you're splitting '' instead of the classname to move on. You could trap the function with if (isset(o)) is probably the easiest test but doesn't explain why o would be undefined. You didn't say what version so I'm guessing on the function here.

if (isset(o)) 
 {
   var parts=o.className.split(' '); 
    var new_parts = Array();
    for (var x = 0; x 

ekrichbaum avatar Apr 06 '20 14:04 ekrichbaum