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

326
Visualizações
Are the objects returned by event.composedPath() deep clones?

During a click event on an html element, I am trying to see whether the element clicked is one particular element.

This particular element is a child element, whose parent also has a click listener. I am trying to prevent the click listener on the parent from also firing.

This seems like exactly what event.stopPropagation() is for, but I am curious...

  1. If there are any drawbacks to using event.stopPropagation()? (This seems to achieve the desired outcome)
  2. If anybody can tell me if the eventTarget objects returned by event.composedPath() (which should be html elements) are deep copies of the actual DOM elements?

For question #2, I am having trouble finding anything in docs or online to answer this.

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

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

const path = event.composedPath();
const heart = document.querySelector('div.heart') as HTMLElement;

if (path.includes(heart)) {
      //I don't want to continue execution, but the html element 'heart' is apparently not part of
     //the Event Target array returned by event.stopPropagation(), even though I can 
     //clearly see it is (or maybe it is just a deep clone?)
     return; 
 }
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