Search code examples
javascripthtmldominternet-explorer-9metatag

Does IE9 load SVG dom in document order?


In Firefox, when a server issues out a pure SVG document to the browser, and a Javascript script element is issued before the SVG elements having onload= events attached to them, one can be assured that an earlier SVG element has been loaded before the next one. Therefore a script can assume that is present in the DOM and is accessible when script tries to access it.

However, in IE9, there seems to be no guarantee or sequence to how the DOM elements load.

Is there a way to force a pure SVG document (no DOCTYPE html5 or meta xua tags) to load in document order in IE9?

Otherwise you have a lot of monkey business in the Javascript to simply assure that elements are loaded in the DOM.


Solution

  • I can't find anything in the SVG or DOM specifications that require elements to load in document order (only that they are painted in that order). If it isn't a requirement then you'll never be guaranteed the behaviour you expect. I think you'll need to rely on that "monkey-business" after all.

    One possibility is to add a child element in the calling element that is a link to a descendant in the target element. That may delay the load event on the source element until the link is loaded.

    Another is that setting externalResourcesRequired="true" on a container element will have the effect of disabling progressive display of the contents of that container, if that container includes elements that reference external resources. In other words by linking to another document and setting that attribute you can disable the streaming behaviour of SVG which might force a complete DOM when the load events fire.