MutationObserver misses mutations during fast DOM schema rollback
0 reputation · 03 Apr 2021, 04:16 UTC
Goal
Ensure that after applying a DOM schema change (such as adding or removing custom data‑attributes) and then rolling back those changes, every intermediate mutation is captured so the rollback can restore the exact original state without leaving stray nodes or attributes.
Constraints and uncertainty
Internet Explorer 10 provides the MutationObserver API, but the specification allows implementations to coalesce rapid mutations into fewer callback invocations. It is unclear whether the takeRecords method can be relied upon to retrieve all pending records in IE10 when mutations occur in quick succession, or whether disconnecting and reconnecting the observer during a rollback risks losing notifications.
Specific questions:
- Does invoking
takeRecordsimmediately after each mutation guarantee retrieval of every pending MutationRecord in IE10? - If the observer is disconnected and reconnected during the rollback sequence, can any mutations be missed?
- Can the order of items in the mutationList be trusted to reconstruct the pre‑change DOM state?