clobba / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

doc error? obj.addEventListener("load", foo, false) doesn't work in Firefox #564

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The instructions for dynamically inserting SVG <object>s into the document say 
to do this to get notified when the SVG has finished loading:

    var obj = document.createElement('object', true);
    obj.setAttribute('type', 'image/svg+xml');
    ...
    obj.addEventListener('load', function() {
      alert('loaded!');
    }, false);

This only works reliably in Webkit-based browsers.  In Firefox, only the event 
listener on the *first* such inserted object will be called; all subsequent 
objects' event listeners are not called.

Doing 

    obj.onsvgload = function() { ... };

works reliably in Firefox as well as Webkit-based borwsers.

Original issue reported on code.google.com by zack.weinberg on 28 Oct 2010 at 4:06

GoogleCodeExporter commented 9 years ago
What version of Firefox? Perhaps this is a regression with newer versions of 
Firefox. Also, is this with native SVG or Flash SVG on Firefox? Can you attach 
a reduced test case?

Original comment by bradneub...@gmail.com on 16 Nov 2010 at 10:15

GoogleCodeExporter commented 9 years ago
Testing was with both Firefox 3.6.recent (11, 12) and Firefox 4.0b6, using the 
native renderer.  I do not have a simplified test case and will not be able to 
produce one quickly, but please remind me if I don't get back to you with one 
by December 1.

Original comment by zack.weinberg on 16 Nov 2010 at 10:23

GoogleCodeExporter commented 9 years ago
I added tests for this issue in r1308. I am unable to reproduce the problem as 
reported.

Original comment by grick23@gmail.com on 31 Dec 2010 at 2:31

GoogleCodeExporter commented 9 years ago
Actually I was able to find a problem with that test file similar to the 
problem you reported. If I clear the firefox browser cache and load that file 
(tests/browser-tests/issues-tests/issue564.html) in native mode, then the 
second object listener is "broken". The listener is called, but it cannot find 
the object element for some odd reason. I noticed this problem does not exist 
with an older revision and was able to trace the problem back to r1193. I found 
that I had broken a workaround Brad had implemented for a related bug in 
firefox. That is described in the NativeHandler._patchAddEventListener call in 
src/svg.js.

I just fixed the problem I introduced in r1193 in r1309. So, maybe this will 
fix the problem you were seeing.

Original comment by grick23@gmail.com on 31 Dec 2010 at 4:10