W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2012

[Bug 19007] New: additional function request for Mutation methods (5.2.2)

From: <bugzilla@jessica.w3.org>
Date: Tue, 25 Sep 2012 12:52:51 +0000
To: www-dom@w3.org
Message-ID: <bug-19007-4009@http.www.w3.org/Bugs/Public/>

           Summary: additional function request for Mutation methods
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
        AssignedTo: annevk@annevk.nl
        ReportedBy: pomax@nihongoresources.com
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, www-dom@w3.org

The new DOM mutation methods are excellently great, but I would like to request
the addition of one more function: swap.

Particularly for DOM diffing (turning one element into another) where the
operations are removals, insertions and relocations, as well as "collection"
relocations (moving a sequence of elements up/down in their container) a swap()
operation will greatly improve legibility as well as writability.

Compare these two DOM fragments:


  <!-- guide text -->


  <!-- guide text -->

Turning A into B (as a diff, or because a user did something that was
equivalent to a drag operation on the first two or last two non-Text nodes)
using a .swap() operation would be a two line constructions:

  figure.swap(1,5); // or figure.swap(commentElement1, commentElement2)
  figure.swap(2,6); // or figure.swap(imgelement, figCaptionElement)

This code would be preferable to having to relocate elements using inserts,
where each insert must be followed by checks to see whether a relocation now
requires an insert, or an append because the next swap can be performed.

It would also reduce the number of DOM mutation events being generated for a
swap from two events that are either the same (two inserts) or different (an
insert and an append) to a single event that always represents a swap.

Configure bugmail: https://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, 25 September 2012 12:53:11 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:19 UTC