Fix overlapping MutationObserver registrations, with credit to #68 - #83
Conversation
Adapt the interested-observer aggregation from #68 so matching ancestor registrations can request old values without producing duplicate records. Credit 7HR4IZ3 beside the implementation and in the regression tests. Validate contradictory observer options, infer omitted mutation types from option presence, and release inactive observers from the global registry. Document the existing synchronous callback behavior. Validation: 248 passed, 89 subtests passed across the observer, DOM and insertion ownership tests. The 22 new cases produce 11 failures against the unchanged baseline and all pass with this change. Co-authored-by: 7HR4IZ3 <90985774+7HR4IZ3@users.noreply.github.com>
PR Summary by QodoPreserve old values across overlapping MutationObserver registrations
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab) |
When one MutationObserver watches a child directly and its ancestor with subtree and old-value capture enabled, the direct registration previously hid the ancestor's old-value request. Combine all matching registrations and deliver one record with the requested old value for attributes and character data.
Adapted from 7HR4IZ3's interestedObservers aggregation in #68, with credit in the code and tests and a verified Co-authored-by trailer.
Also reject contradictory observe options, infer omitted mutation types from option presence, and release inactive observers from the global registry. Synchronous delivery is documented; browser microtask batching remains unimplemented.
Validation: 248 tests and 89 subtests passed across tests/test_dom_mutation_observer.py, tests/test_dom.py, and tests/test_dom_insertion_ownership.py. The 22 new cases produce 11 failures against the unchanged baseline and all pass after the fix. The principal regression is test_overlapping_observations_preserve_old_value, covering attributes and character data, both registration orders, and old-value requests on either registration.
Follow-up to #68.