Re: [whatwg/dom] Make it possible to observe connected-ness of a node (#533)

trusktr left a comment (whatwg/dom#533)

> type NodeLifeEntryCase =
>   | "connected"
>   | "disconnected"
> 
>   | "parentChanged" // or `reparented`.
>   | "parentConnected"
>   | "parentDisconnected"
> 
>   | "documentConnected"

What's the need for `parentConnected` (and the other parent hooks) vs the connected/disconnected? Is it that you want to run logic when an element is connected/disconnected in an inert tree that is not in the DOM? If so, I'm not sure that this is a good idea: for example the content of a `<template>`'s `.content` document is meant to be *inert* and we should avoid running logic on those trees. The idea is that when a element is connected into the live DOM (`connected`), that's when we load stuff.

Also, from the perspective of designing something simple enough for everyone to get on board with, maybe having all of that in a single proposal is too much. Could you trim down your proposal to only this,

> type NodeLifeEntryCase =
>   | "connected"
>   | "disconnected"

without the other hooks, and without `ElementLifeObserver`? We could always expand on something later, but trying to get something like that all in at once (including `ElementLifeObserver`) would be too difficult I think. They're not bad ideas (my previous comment links to much needed similar API ideas for observing style/reflow/etc), just that we may have a better time making focused incremental changes.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/533#issuecomment-2833648418
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/533/2833648418@github.com>

Received on Sunday, 27 April 2025 21:28:26 UTC