1.3.1 • Published 4 years ago
dom-element-path v1.3.1
dom-element-path
Get unique dom element path for specified element.
Installation
npm:
npm install dom-element-pathyarn:
yarn add dom-element-pathUsage
import domElementPath from 'dom-element-path';
const body = domElementPath(document.body);
console.log(body);Output:
html > bodyOne of the common use cases is where you have event in some sort of event handler and want to get path of element that the event was fired off:
import domElementPath from 'dom-element-path';
const onClick = event => {
const clickedElementPath = domElementPath(event.target);
console.log(clickedElementPath);
};Output:
html > header > div.header-menu > ul > li:nth-of-type(4) > a.login-buttonDevelopment
run linter:
yarn lintrun tests:
yarn testcreate build:
yarn build