W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Some way to change an element's name would be useful

From: Robin Berjon <robin@berjon.com>
Date: Mon, 29 Aug 2011 21:33:57 +0200
Cc: W3C WebApps WG <public-webapps@w3.org>, Ryosuke Niwa <rniwa@webkit.org>, Ehsan Akhgari <ehsan@mozilla.com>
Message-Id: <CBE370C8-E977-4EB3-B951-43D61953860B@berjon.com>
To: Aryeh Gregor <ayg@aryeh.name>
On Aug 29, 2011, at 20:57 , Aryeh Gregor wrote:
> We can't actually change the tag name of the node in place, because
> then it will have to implement a different interface in general.  But
> we could have a setTagName() method that creates a new Element with
> the given tag name, moves the children, copies the attributes, puts it
> in the right place, fixes up the Ranges, then returns the
> newly-created Element.  Does this seem reasonable to anyone, or is it
> too confusing that the object will be different?

I've often had a need for this, and I agree that it would be useful. It certainly is confusing that it returns a different object but maybe we can alleviate that problem somewhat with a different method? Not to bikeshed, but setTagName() sounds like you're setting a property of a given object, which makes the object change confusing. Perhaps something like renameElement() would be clearer? Or getRenamedElement()?

For completeness, I'm guessing that namespaces would be supported as well?

Element renameElement(DOMString newName);
Element renameElement(DOMString newNS, DOMString newName);

Robin Berjon - http://berjon.com/ - @robinberjon
Received on Monday, 29 August 2011 19:34:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:23 UTC