Open Bug 711821 Opened 9 years ago Updated 2 years ago

Range.createContextualFragment sets wrong namespace when context is an SVG node


(Core :: DOM: Core & HTML, defect, P5)






(Reporter: costan, Unassigned)



(1 file)

Attached file Test case
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11

Steps to reproduce:

I used the createContextualFragment DOM Range API, with the context element set to a SVG element. I attached a reduced test case.

Spec at

Actual results:

The nodes in the resulting DocumentFragment have their namespaces set to the HTML namespace, not to the SVG namespace.

Expected results:

The nodes in the resulting DocumentFragment should have their namespaces set to the SVG namespace, so I can add them to the SVG element :)

In the attached test case, the black <circle> coming from the SVG fragment should overlap the red <circle> in the initial SVG.
Chrome bug at
This would be useful for visualizations and games. A real use-case is that I'd like to pull data for a unit model, set it as a <symbol>, and then <use> it to render multiple units with the same model.

Thank you for looking into this!
Attachment #582654 - Attachment mime type: text/plain → text/html
That's what the specification says. Have you emailed the whatwg and suggested it be changed?
Thank you for your answer, Robert!

I'd definitely like to email the WHATWG if this is spec behavior, because I don't think it's the right thing to do. Can you please help me where did my train of thought fail?

1. The fragment parser will be invoked with <svg> as the context element.

2. The XML parsing algorithm will be selected.

3. The default namespace will be the SVG namespace.

Thank you so much!
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.