Bug 103916 - MutationObservers should be passed unique MutationRecords
Summary: MutationObservers should be passed unique MutationRecords
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: WebExposed
Depends on:
Blocks: 68729
  Show dependency treegraph
 
Reported: 2012-12-03 12:20 PST by Adam Klein
Modified: 2017-07-18 08:29 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Klein 2012-12-03 12:20:32 PST
This is per a change to the DOM spec: see https://www.w3.org/Bugs/Public/show_bug.cgi?id=20131 and https://github.com/whatwg/dom/commit/b5d05659b682b2560af6c24e2e2cdbace82811d3

To minimize the memory impact/mutation-time cost,  we could create these unique records only at delivery time (when we're already walking through the list of records to move them from a WTF::Vector to a JS array). Or if we want to get fancy we could build machinery to give each observer its own JS wrapper around a single record.
Comment 1 William J. Edney 2015-01-08 11:43:09 PST
This bug really caused me a lot of confusion. I have a long-lived MO that observes changes on the #document node (observing both childList and subtree, of course). I wondered why I was seeing a lot of the same Mutation Records over and over again (and this list grows as my app runs).

For now, I mark these objects with an expando slot to let me know the record has already been processed, but this should be unnecessary (and it's wildly inefficient to be called with records I've already processed).