event-target is an event target library that offers ways to check the element which event is targeting.
npm - ag--event-target
I advise to globaly install browserify and watchify, which both allow to test the whole thing in the browser:
npm i -g browserify watchify
let EventTarget = require('ag--event-target');
let target = new EventTarget();
target
will now offer some method to test it.
Returns the element targeted.
Return all children of a parent element, where parent
is a dom element.
Where element
is a dom element. Return wether the targeted element === element
.
Return the targeted element's attr
attribute.
Return the targeted element's data-attr
data attribute
Return wether the targeted element has the classe
class
Return true if the targeted element's id is id
Return wether the targeted element's attr
attribute has the value value
Return wether the targeted element is part of selectors
, where selectors
is one or more css selectors, comma seperated
Return wether the targeted element is a parent of selector
, where selector
is a css selector
Return wether the targeted element is child of selector
, where selector
can be a string css selector, or a dom element
Return the first targeted element's parent that matches selector
, where selector
is a css selector
Return the first targeted element's child that matches selector
, where selector
is a css selector