Re: Element.createElement proposal
Jonas Sicking <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
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). / Jonas