- From: Oxford Harrison <notifications@github.com>
- Date: Mon, 23 Sep 2024 15:41:58 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1287/2369668247@github.com>
> Over in > > * [observing the composed tree synchronously webqit/realdom#3](https://github.com/webqit/realdom/issues/3) > > @ox-harris implements `options.subtree = 'cross-roots'` in the `realdom` lib for synchronously observing added/removed elements across shadow root boundaries, and gets us a little closer to synchronous observation of the composed tree (f.e. detect composed children, composed parent, etc). > > Not only is the usage simpler than with `MutationObserver` (because [MO events fire out of order](https://github.com/whatwg/dom/issues/1111)) and lead to simpler code, but composed tree tracking code will also be as simple when that's ready (`ComposedChildrenObserver`, `ComposedParentObserver`, `ComposedMutationObserver`, etc). Thanks @trusktr for the mention. Re: the above, there's been a clear misfit between what I do and what the MutationObserver APi does. For example, I sometimes just want to say: + observer the `style` attribute (or `draggable` attribute, etc) globally. Which exactly means "also within Shadow trees". + do that synchronously, so that I can closely mimic native timing for the behaviour I want to attach to the element. + and in some of those cases: do that *ahead of* native timing; i.e. let me intercept this attribute before the DOM sees it. E.g. to rewrite animation properties in the `style` attribute before the 'animationstart` event fires. (A reallife usecase: implementing the upcoming OOHTML proposal.) It turns out to be extremely difficult and mostly impossible to use the MutationObserver API in those scenarios. Writing the above referenced library - [RealDOM](https://github.com/webqit/realdom) - a realtime, and more declarative, DOM API, was the logical answer. Now, while I didn't to pursue that as a proposal, perhaps some of ideas there could help in the ideation in here. PSS: I didn't pursue that as a proposal because I was unsure how much typical my usecase was. But I think it's more of a moving story now. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1287#issuecomment-2369668247 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1287/2369668247@github.com>
Received on Monday, 23 September 2024 22:42:02 UTC