[Bug 19402] MutationObservers: 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

Rafael Weinstein <rafaelw@chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugs@pettay.fi

--- Comment #2 from Rafael Weinstein <rafaelw@chromium.org> ---
Anne,

You are correct that this only affects characterData and attributes (not
childList).

I don't think checking the last record in the queue is the right approach. The
spec is pretty clear that no-op changes still generate mutation records. So
with this approach,

setAttribute('foo', 'bar');
setAttribute('foo', 'bar');

will only generate one record, and I've already seen code in the wild depending
on setAttribute *always* creating a mutation record.

I think the "right" way to spec this is unfortunately more complicated. Perhaps
Adam can weigh in here. I'd be tempted to implement it the way that webkit (and
I'm guessing gecko) does:

1. Define an "Interest Group" which is a mapping of Observer -> Delivery
Options, which is initially empty.
2. Start at |target| and walk in the ancestor chain. For each node, visit the
registered and transient observers and add them to the map if they care about
the given mutation type (and have subtree set if the current node isn't
|target|. If a given observer is already present in the map, the Delivery
Options are OR'd into the existing options.
3. Now enqueue either the record or recordWithOldValue for each observer,
depending on whether the delivery options specify old value.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 15 October 2012 17:52:33 UTC