Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!