Bug 20506 - WRONG_DOCUMENT_ERR: DOM Exception 4 with JavaScript's 'document' object and XHTML-inline SVG
Summary: WRONG_DOCUMENT_ERR: DOM Exception 4 with JavaScript's 'document' object and X...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.5
: P2 Minor
Assignee: Nobody
URL: http://pastie.org/259289
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-25 00:21 PDT by elliottcable
Modified: 2019-02-06 09:03 PST (History)
2 users (show)

See Also:


Attachments
test case (2.55 KB, application/xhtml+xml)
2008-08-25 03:26 PDT, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description elliottcable 2008-08-25 00:21:58 PDT
Error: WRONG_DOCUMENT_ERR: DOM Exception 4

http://pastie.org/259289 (line 59)

I could be wrong (I'm a noob to this stuff), but I believe this has something to do with trying to refer to the 'document' object in JavaScript with embedded SVG within an XHTML document (true XHTML, with proper markup and served as application/xhtml+xml).
Comment 1 elliottcable 2008-08-25 01:22:39 PDT
After some more debugging, I find that the line causing the error is in fact line 59 of this slightly modified test case:

http://pastie.org/259289

So it has something to do with appendChild, though I'm still not sure exactly what.
Comment 2 Alexey Proskuryakov 2008-08-25 03:26:55 PDT
Created attachment 22976 [details]
test case

Attaching the same test as an attachment.

It is not immediately obvious whether this is a bug or just a difference with Firefox. In any case, you can probably work around this by using importNode to ensure that the nodes are in the same document.
Comment 3 elliottcable 2008-08-25 09:53:20 PDT
(In reply to comment #2)
> It is not immediately obvious whether this is a bug or just a difference with
> Firefox. In any case, you can probably work around this by using importNode to
> ensure that the nodes are in the same document.

Not sure about that - trying to debug the same original code in FireFox as well, right now, causes other, even weirder errors there ("[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMHTMLDocument.importNode]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://geoffrey.elliottcable.name/board/4/game_board_4.xhtml :: writeSVG :: line 355" data: no]"? What does that even _mean_?)
Comment 4 elliottcable 2008-08-25 09:57:44 PDT
Another thing worth pointing out is that FireFox chokes up on the use of ( new DOMParser() ).parseFromString(svgSource, "text/xml") when the source is SVG - it returns XML objects, not the SVG objects that it actually uses internally for SVG elements. Thus there's problems with XML/SVG documents and using that - perhaps there's a similar problem going on under the hood here?
Comment 5 Lucas Forschler 2019-02-06 09:03:18 PST
Mass moving XML DOM bugs to the "DOM" Component.