- From: Ronald Zielaznicki <notifications@github.com>
- Date: Thu, 30 Mar 2023 16:56:39 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/126/1491107182@github.com>
I'll take a stab at that proposal. # Proposal ## Use Cases * Stop observing nodes when they are moved elsewhere in the DOM - as seen in https://github.com/vaadin/web-components/pull/2714#discussion_r720440236 - refers to moving the node observed, not its children * Defer Elements for Hydration - as seen in Fast https://github.com/microsoft/fast/issues/6403 - Fast ended up implementing their own version of [unobserve](https://github.com/microsoft/fast/blob/d38d31d2dd7496b5eb1e7c65b57de9a5e05e8546/packages/web-components/fast-element/src/utilities.ts#L91) ## Changes * Add `MutationObserver.prototype.unobserve(target, callback)` - target: [Node](https://dom.spec.whatwg.org/#node) - callback: optional [MutationCallback](https://dom.spec.whatwg.org/#callbackdef-mutationcallback) - stops new MutationRecords for target from queuing - removes any MutationRecords for target from queue - calls callback with MutationRecords removed from queue, if callback defined ----- Tried to keep in line with [Resize.prototype.unobserve](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/unobserve) while balancing the need to do something with any MutationRecords in the current queue in a way that is intuitive to web developers. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/126#issuecomment-1491107182 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/126/1491107182@github.com>
Received on Thursday, 30 March 2023 23:56:51 UTC