admin管理员组

文章数量:1426072

When I click on an SVG element I get an error on Chrome but not on Firefox.

If I use the Chrome's debugger it breaks in bubble_piled.js (Google's file) with an 'Uncaught TypeError: undefined is not a function'.

I know the underlying issue stems from ''.className returning an SVGAnimatedString (which doesn't have an indexOf method) and the correct thing to do is use .classNam e.baseVal but again this error is not part of my code rather it's part of google's code.

Here is a basic example:

<!DOCTYPE html>
<html>
<head>
    <script>
       function err() { alert('err'); }
    </script>
</head>
<body>
   <svg style="width:200px;height:200px; background-color: #00B7FF" onerror="err()"></svg>
</body>
</html>

Unfortunately this means that I can't debug my code that involved interactions with an svg element because Chrome debugger breaks on this error on mousedown.

Interestingly I didn't see this problem until two days ago (May 14th) and I've been developing such code for several years. I'm using Chrome 42 on the mac and I've tried using Chrome 40.0.2214.91 (64-bit) but now I get the same error (yes, I disabled Chrome automatic update :-) I don't see the problem in Firefox (with or without a debugger).

Another interesting observation is that the error doesn't occur if I load the above html from a file rather (file://) than via a server.

I tried to circumvent it by adding an indexOf() to SVGAnimatedString (or its prototype) but this is native code and it doesn't work.

Adding onmousedown to the svg element doesn't help because the exception occurs before my function is called.

All I need for now is a way to tell Chrome not to break on this error.

When I click on an SVG element I get an error on Chrome but not on Firefox.

If I use the Chrome's debugger it breaks in bubble_piled.js (Google's file) with an 'Uncaught TypeError: undefined is not a function'.

I know the underlying issue stems from ''.className returning an SVGAnimatedString (which doesn't have an indexOf method) and the correct thing to do is use .classNam e.baseVal but again this error is not part of my code rather it's part of google's code.

Here is a basic example:

<!DOCTYPE html>
<html>
<head>
    <script>
       function err() { alert('err'); }
    </script>
</head>
<body>
   <svg style="width:200px;height:200px; background-color: #00B7FF" onerror="err()"></svg>
</body>
</html>

Unfortunately this means that I can't debug my code that involved interactions with an svg element because Chrome debugger breaks on this error on mousedown.

Interestingly I didn't see this problem until two days ago (May 14th) and I've been developing such code for several years. I'm using Chrome 42 on the mac and I've tried using Chrome 40.0.2214.91 (64-bit) but now I get the same error (yes, I disabled Chrome automatic update :-) I don't see the problem in Firefox (with or without a debugger).

Another interesting observation is that the error doesn't occur if I load the above html from a file rather (file://) than via a server.

I tried to circumvent it by adding an indexOf() to SVGAnimatedString (or its prototype) but this is native code and it doesn't work.

Adding onmousedown to the svg element doesn't help because the exception occurs before my function is called.

All I need for now is a way to tell Chrome not to break on this error.

Share Improve this question asked May 16, 2015 at 18:55 YardenYarden 1316 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

Turns out the issue is due to Google's Translate extension. Disabling it solve the problem.

本文标签: javascriptChrome and a TypeError due to SVGAnimatedStringStack Overflow