[Bug 13971] New: Define a renameNode method

http://www.w3.org/Bugs/Public/show_bug.cgi?id=13971

           Summary: Define a renameNode method
           Product: WebAppsWG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DOM Core
        AssignedTo: annevk@opera.com
        ReportedBy: ayg@aryeh.name
         QAContact: member-webapi-cvs@w3.org
                CC: mike@w3.org, www-dom@w3.org


Discussion:

http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1088.html

DOM 3 Core defined a renameNode() method that no one implemented.  Ehsan,
Ryosuke, and I agreed at our face-to-face meeting that such a thing would be
useful for editing.  Dimitri said in that thread that he thinks it would be
useful for Component Model.

The existing definition leaves too many things undefined, though, and has other
bad traits (like sometimes replacing the node and sometimes not, and being on
Document instead of Element).  Things it should do:

* Should be a method on Element, probably called renameElement() or just
rename().
* For consistency/completeness, probably should take a single argument that's
the new name, which will be lowercased for HTML documents, and have a
rename(Element)NS() variant.
* Always make a new element with the desired name.  Don't ever leave the
existing one in place.
* Copy all DOM attributes, event listeners, and custom JS properties that were
stuck on the object.
* Move all range endpoints appropriately.  (This can be left to DOM Range as
long as it's not yet merged into Core.)
* Stick the new node next to the old one, move all the children, then remove
the old one.
* Return the new node.

This is pretty nontrivial for authors to get right, and on some points
impossible in general (like updating all range endpoints), so it seems like a
good thing for browsers to implement.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Tuesday, 30 August 2011 16:48:41 UTC