Socket
Socket
Sign inDemoInstall

chrome-dompath

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-dompath

Chrome DevTools DOMPath implementation


Version published
Weekly downloads
1.7K
decreased by-37.37%
Maintainers
1
Weekly downloads
 
Created
Source

This package is a little piece of Google's Chromium DevTools project which modified to make it work on JSDOM.

The DOMPath is responsible for generating a selector given an element in a particular DOM hierarchy. Its methods can be accessed via the following menu:
Open DevTools -> Navigate to Elements tab -> Right click on selected Element -> Copy DOMPath-use

Installation

NPM Version NPM DownloadsLicense

npm i -S chrome-dompath

DOMPath

Get selector, JS Path and XPath of a DOM element.

const DOMPath = require('chrome-dompath');

// Node
const dom = new JSDOM('<root><a><b>T1</b><c>T2</c></a></root>').window.document;
const element = dom.querySelector('b');

// Browser
const element = window.document.querySelector('b');

DOMPath.fullQualifiedSelector(element, true);
DOMPath.jsPath(element, true);
DOMPath.xPath(element, true);

API

DOMPath.fullQualifiedSelector(node: DOMNode | optimized: boolean)

Returns the full qualified selector (string) for the node supplied.

DOMPath.fullQualifiedSelector(element);
DOMPath.fullQualifiedSelector(element, true);

DOMPath.jsPath(node: DOMNode | optimized: boolean)

Returns the JS path (string) for the node supplied.

DOMPath.jsPath(element);
DOMPath.jsPath(element, true);

DOMPath.xPath(node: DOMNode | optimized: boolean)

Returns the xpath (string) for the node supplied.

DOMPath.xpath(element);
DOMPath.xpath(element, true);

Keywords

FAQs

Package last updated on 04 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc