[Bug 19402] New: MutationSummary: When appending a record to the queue the last item needs to be replaced if it represents the same mutation and the new record has an oldValue

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19402

           Summary: MutationSummary: When appending a record to the queue
                    the last item needs to be replaced if it represents
                    the same mutation and the new record has an oldValue
           Product: WebAppsWG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
        AssignedTo: annevk@annevk.nl
        ReportedBy: arv@chromium.org
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, www-dom@w3.org


When appending a record to the queue the last item needs to be replaced if it
represents the same mutation and the new record has an oldValue.

This can happen if there are more than one registered observer.

var div = document.createElement('div');
var child = div.appendChild(document.createElement('div'));
child.setAttribute('a', 'A');
var observer = new MutationObserver(function() {});
observer.observe(child, {
  attributes: true
});
observer.observe(div, {
  attributes: true,
  subtree: true,
  attributeOldValue: true
});
child.setAttribute('a', 'B');
var records = observer.takeRecords();
assert(records.length === 1);
assert(records[0].type === 'attributes');
assert(records[0].target === child);
assert(records[0].attributeName === 'a');
assert(records[0].oldValue === 'A');

Both Gecko and WebKit pass this test but the spec algorithm creates 2 records.
If the tree is deeper and there are more registered observers this can get
larger.

The problem this causes is that there can be multiple records delivered to the
same observer representing the same mutation.

The proposed solution is to add a an algorithm called append record which takes
a list of records and the record to append.

1. If the list is non-empty and the last item in the list represents the same
mutation and the current record represents a record with oldValue replace the
last item in the list.
2. Otherwise, append the record.

This is a bit vague because we haven't defined what it means that two records
represent the same mutation. Same thing goes for defining whether the record
has an oldValue or not.

-- 
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, 9 October 2012 17:46:52 UTC