I'm using Polymer 1.0 and when there is a click on a button in Chrome a MouseEvent
is generated. This MouseEvent
object has a path
property which is an ordered array of parent elements to the clicked button. In Firefox & Safari, however, a click
is generated which does not have a path
property. Is there an equivalent property of the click
object which gives me the same information?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
It's not available, but if you really would like to have this property, then you could extend the native prototype of the Event object like so:
However if I were you, I wouldn't extend the prototype - I would create a function like mentioned above instead.
Also I would change Event.prototype to MouseEvent.prototype if you want to cover only those types of events.
It seems like the e.composedPath() method might be a cross-browser version of
e.path
. It works in Chrome and Firefox. Not sure about Safari.