mustang2247 / svgweb

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

Event handler problem. #455

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The 'addEventListener' is not exposed for the locally wrapped element.
See the attached example file.
Even doing that from outside the object is not getting the event setup.
However, using a simple setAttribute('onclick', handler); is working correctly.

Original issue reported on code.google.com by Omar.Bel...@gmail.com on 19 Feb 2010 at 8:58

Attachments:

GoogleCodeExporter commented 8 years ago
Yes, this is an unfortunate problem we know about. It is documented in the User
Manual under "Knowing When Your SVG Is Loaded":

  If you dynamically create SVG root elements _after_ the page has already
  finished loading, you must add an SVGLoad listener to the SVG root
  element before you can add further children (note: this is a divergence from the
  SVG 1.1 standard, and is needed due to the asynchronous Flash and
  Microsoft Behavior magic going on under the covers to bootstrap different
  parts of the library)

Here is how your example would need to change:

      window.onload = function() {
        root = document.createElementNS(svgns, 'svg');
        root.setAttribute('id', 'svgRoot');
        root.setAttribute('width', '100%');
        root.setAttribute('height', '100%');
        root.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
        function svgload() {
          var root = document.getElementById('svgRoot');
          var cir = new Circle(100, 100, 40, 'blue', 'red', '10', 0.4);
          root.appendChild(cir);
        }
        root.addEventListener('SVGLoad', svgload);
        svgweb.appendChild(root, document.body);
      };

Marking as "won't fix" since this is a known problem we have no plans to deal 
with
further. 

Original comment by grick23@gmail.com on 28 Mar 2010 at 7:40