question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add event.composedPath()

See original GitHub issue

Events dispatched through jsdom seem to be missing the path property: https://dom.spec.whatwg.org/#event-path

An event has an associated path. A path is a list of tuples, each of which consists of an item (an EventTarget object) and a target (null or an EventTarget object). A tuple is formatted as (item, target). A path is initially the empty list.

Not quite sure what it would require to support this, but if you could give me some pointers, I can attempt an implementation.

Is there any other API jsdom provides that would help determine the path an event is bubbling through?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
amsulcommented, Jul 14, 2016

Okay, for anyone wondering, this seems to be a decent enough workaround for now:

function getEventPath(event) {

  if (event.path) {
    return event.path
  }

  let path = []
  let target = event.target

  while (target.parentNode) {
    path.push(target)
    target = target.parentNode
  }

  path.push(document, window)

  return path

}

@domenic feel free to close this as it is beyond the scope of jsdom atm.

2reactions
tomaleccommented, Jan 5, 2018

Just to update, it seems latest Chrome supports composedPath http://jsbin.com/vepohu/3/edit?html,console,output

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event.composedPath() - Web APIs - MDN Web Docs
The composedPath() method of the Event interface returns the event's path which is an array of the objects on which listeners will be ......
Read more >
composedPath() Event Method - W3Schools
The composedPath() method returns an array of objects containing the elements in the event flow, in the correct execution order.
Read more >
Event.composedPath() - Web APIs
The composedPath() method of the Event interface returns the event's path which is an array of the objects on which listeners will be...
Read more >
determine event path in DOM Event bubbling - Stack Overflow
The composedPath() method of the Event interface returns the event's path which is an array of the objects on which listeners will be ......
Read more >
DOM Structures with Event composedPath - YouTube
This tutorial explains how you can use the Event composedPath () method to determine the entire DOM path from the element that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found