returns HTMLDocument instead of SVGDocument




11 years ago
2 years ago


(Reporter: Cory Cohen, Unassigned)


(Depends on: 1 bug, {dev-doc-needed})

Firefox Tracking Flags

(Not tracked)




11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20070515 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20070515 Firefox/

This looks like a bug to me, but 

Reproducible: Always

Steps to Reproduce:
function init() {
  var win ='test.svg', '', '');
  var myrect = win.document.createElementNS("", "rect");
<body onLoad="init()"></body>
<?xml version="1.0"?>
<svg xmlns="" xmlns:xlink="">
  <rect x="10" y="10" width="100" height="100" fill="red"/>
Actual Results:  
The alert displays "[object HTMLDocument]".  Subsequent attempts to use the document produces errors like:

Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy"  code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)"  location: "file:///C:test.html Line: 8"]

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLHtmlElement.appendChild]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: chrome://xxx/test.xul :: init :: line 38"  data: no]

Expected Results:  
I would expect win.document to have a document of type of SVGDocument, and display  "[object SVGDocument]".

If this is somehow expected behavior, sorry for the bogus bug report, but this appears to be broken to me...

Comment 1

11 years ago
If I wait a while, the correct result is returned.  It looks like simply getting out of the onLoad event is enough. Changing the code to: 

var win;
function init() {
  win ='test.svg', '', '');
  setTimeout("later()", 1);
function later() {

correctly alerts "[object SVGDocument]".  This seems very hackish, and strongly suggests to me that this behavior is indeed a bug.  On the other hand, now that I see that the problem is clearly an ordering issue, and that the doesn't occur until after the onLoad event exits, I suppose it's possible that nothing can be done to correct it.

Is there anywhere that all this fine print gets recorded?  I sometimes find it nearly impossible to code using Javascript and the DOM because functions do _NOT_ behave exactly as documented, but rather that way most of the time.  This routinely leaves me figuring out _why_ it doesn't do what it says it will. :-(

Comment 2

11 years ago
There is much of DOM and DOM:Events changes on trunk. What happens if you try your code against trunk? 


6 years ago
Depends on: 512688
No longer depends on: 512688
Depends on: 897815
Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.