[whatwg] Range.createContextualFragment in SVG contexts
costan at gmail.com
Sun Dec 22 08:08:40 PST 2013
I'm trying to re-implement Range.createContextualFragment in Blink
following this whatwg spec:
There are two issues I'd like to discuss, related to the use of
createContextualFragment in SVG contexts.
1) If a Range's context is an <svg> element, I think the XML parsing
algorithm should be selected, so the elements in the resulting
DocumentFragment would get the SVG namespace. This way, inserting the
fragment in an <svg> tree would have the intended effect.
(the red circle should be completely covered by a black circle)
2) If a Range's context is an SVG document, step 2 in the
createContextualFragment algorithm will see a null element, and I
think it should create an element in the SVG namespace (not the HTML
namespace) with the local name "svg" (not "body").
Again, this is so that inserting the resulting DocumentFragment in the
<svg> tree would work as intended.
I spent a bit of time thinking of how one would get a Range pointing
to an SVG document, to see if this issue even applies to HTML5. I
eventually found that using <svg> inside <embed> creates an SVG
document inside the HTML5 document, so I can use createRange on the
HTML5 document, and then pass the SVG document to Range.setStart. I
can post code if it helps make this clearer.
I look forward to your thoughts and comments.
More information about the whatwg