Conversation
Added MutationRecord and MutationObserver classes
Added a global instantiation of the 'current' variable which was previously only created when looping through the child of the target node, but is also accessed outside the loop causing the function to fail for single nodes with no children.
|
Thank you @7HR4IZ3 for putting the work into this, and sorry it took so long to give it a proper review. Revisiting the implementation against both its original base and current domonic revealed something useful: your interestedObservers aggregation correctly combines old-value requests when the same observer is registered on a node and on an ancestor. Our current implementation stopped at the first matching registration and could lose the ancestor's old-value request. Your approach helped identify and fix that gap. I've adapted that part in follow-up #83, with credit beside the implementation and a Co-authored-by trailer using the identity from your original commit. The key regression is test_overlapping_observations_preserve_old_value. It covers attribute and character-data changes, both registration orders, and old-value requests on either registration, while checking that only one record is delivered. The follow-up also adds option-validation and observer-lifecycle tests. Across the new observer tests and existing DOM/insertion tests, 248 tests and 89 subtests pass. Eleven of the 22 new cases fail against the unchanged baseline and pass with the fix. The full original patch would still need substantial rework: checking it against its base exposed cloning and other DOM regressions, and its polling delivery differs from browser mutation-observer scheduling. Domonic has also changed considerably since then, so the follow-up preserves the useful aggregation behavior in the current implementation rather than merging the whole old patch. The follow-up is currently a draft, and this PR remains open pending that review. I appreciate the contribution—there was a concrete, correct idea here that improves domonic today. |
Fix overlapping MutationObserver registrations, with credit to #68
I added MutationObserver and MutationRecord classes implemented according to the html specification.