lewisje / svgweb

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

SVGWeb does not load on Firefox when page has an embedded XSL PI (DOMContentLoaded not fired) #506

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce the problem:

1. Create an (X)HTML with an XSL PI which loads svgweb (I have used
svgweb-2010-04-09). For instance:

<?xml-stylesheet  href="/forms/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
        <head>
                <script type="text/javascript"
src="/js/svgweb/svgweb.js"></script>
.
.
.

The page should also dynamically load some SVG drawing using javascript.
For instance, calling next code:

function createSVG(url, parent, width, height, eventListener) {
    try {
    var svg = document.createElement('object',true);
    svg.setAttribute('type','image/svg+xml');
    svg.setAttribute('data',url);
    if(width!=undefined && width!=null)
        svg.setAttribute('width' , width);
    if(height!=undefined && height!=null)
        svg.setAttribute('height' , height);

    if(typeof eventListener == 'function')
        svg.addEventListener('load',eventListener,false);

    svgweb.appendChild(svg,parent);
        return svg;
    } catch(e) {
        alert(e);
    }
}

2. Then, try loading the page with Firefox (I tried with Firefox 3.6.3 on
Gentoo x86).

You get an alert window with the next message:

        TypeError: this._svgObjects is undefined

This message comes from the svg.addEventListener call. I have been digging
on the bug, and the source of the problem comes from Firefox. When the
browser translates an (X)HTML page, it does not generate a DOMContentLoaded
event, which is needed by svgweb to patch native 'document' object and to
populate any DOM element in HTML tree with needed svgweb structures. I have
found a few traces of this "behavior" in other contexts:

http://code.google.com/p/fbug/issues/detail?id=130#c5
http://markmail.org/message/crbi6vr2kpzhv665
http://markmail.org/message/6qhgd5i2ipztn7ka

Original issue reported on code.google.com by josemari...@gmail.com on 4 Jun 2010 at 9:41