Skip to content

Conversation

@annevk
Copy link
Member

@annevk annevk commented Feb 13, 2023

The existing design had some leaks and was also different from implementations. In particular, assume you have two mutation observers and a change triggered the first one as well as a slot change. Then if in the reaction to the first one a further change triggers the second one it would run before the slot change per the existing specification, but that didn't match implementations and more importantly didn't allow for garbage collection.

Test: https://github.com/web-platform-tests/wpt/blob/master/shadow-dom/slotchange-event.html#L540-L594.

Fixes #713. Fixes #1159. Closes #720.


Preview | Diff

The existing design had some leaks and was also different from implementations. In particular, assume you have two mutation observers and a change triggered the first one as well as a slot change. Then if in the reaction to the first one a further change triggers the second one it would run before the slot change per the existing specification, but that didn't match implementations and more importantly didn't allow for garbage collection.

Test: https://github.com/web-platform-tests/wpt/blob/master/shadow-dom/slotchange-event.html#L540-L594.

Fixes #713. Fixes #1159. Closes #720.
@annevk
Copy link
Member Author

annevk commented Feb 13, 2023

@rniwa @smaug---- @domenic @shaseley @FremyCompany @pmdartus I would appreciate your review!

@shaseley
Copy link
Contributor

LGTM. This matches what Blink's doing with the pending mutation observers.

Copy link

@FremyCompany FremyCompany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will admit I had no recollection of our previous discussion, but after reviewing your change, I think it makes sense. That way, only pending MutationObserver instances are held strongly by the document. All the others get automatically collected when all the elements they are attached to leave the document.

PS: This review will show as a comment as I do not appear to have the rights to mark the PR "Approved" directly, but I think this can likely go ahead.

@annevk
Copy link
Member Author

annevk commented Feb 17, 2023

Thanks! I will merge this somewhere next week assuming Bikeshed issues have been resolved and there's no further feedback.

@annevk annevk merged commit d34d52d into main Feb 20, 2023
@annevk annevk deleted the annevk/gc branch February 20, 2023 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

MutationObserver GC section looks bogus "Append mo to unit of related similar-origin bro..." MutationObserver invocation order

4 participants