Re: Element.createElement proposal
Zack Weinberg <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
Jonas Sicking <[email protected]> wrote: > Zack Weinberg wrote: > > Johnny Stenback <[email protected]> wrote: > >> What I don't like about svgElement.createElement() is that it > >> seems a bit odd to have to find an element to create one, which > >> makes the case where you're inserting SVG into a document where > >> there is no existing SVG such that developers still need to type > >> out that namespace URI they don't want to type out. > >> svgElement.createChild() doesn't make any sense to me as there's > >> no child relationship between the element you use for creating and > >> the element that gets created. > > > > What's wrong with > > > > var parent = document.getElementById("putsvghere"); // HTML elt > > var svg = parent.addChild('svg'); // HTML5 'svg' elt = SVG root > > elt var circle = svg.addChild('circle', {...}); // SVG 'circle' > > > > ? The same would work for <math>. > > In the original proposal this would only work if the element with id > "putsvghere" is an SVG element (which I take it was not the case > since you add an <svg> element into it). What I was trying to indicate with // HTML5 'svg' elt = SVG root is that creation of <svg> (or <math>) could magically switch that element into the SVG (or MathML) namespace, just as in HTML5 parsing. zw