Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
Using MutationObserver, how can I detect a child being removed, even if parent is deleted?

See this:

JavaScript MutationObserver. Observing a child element after observing a parent element triggers no events

If I subscribe to a child after i subscribed to a parent i get no child events.

If I subscribe to document, I get all kinds of events, but if a parent is deleted, then I will not get an event from the parent for a subscribed child.

I do not see how mutation observers are useful at all. Is this really the alternative than to use the deprecated MutationEvent?

https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent

There we have DOMNodeRemovedFromDocument DOMNodeRemoved but with the threat of them possibly stop working any given time.

I do not see how MutationObservers are replacement though.

I would need to jump hoops to get this kind of behavior and likely pay with performance.

I am not prepared to iterate all children of a parent to detect any child nodes that might have subscribed.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda