Socket
Socket
Sign inDemoInstall

compute-xpath

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compute-xpath

A library to generate Xpath based on DOM elements


Version published
Weekly downloads
2
increased by100%
Maintainers
0
Weekly downloads
 
Created
Source

Compute xPath

publish BSD-3-Clause License npm npm dependents npm downloads

This is a library that generates xPath based on DOM elements. The implementation is extracted from Chrome DevTools Frontend

Introduction

You can generate xPath based on DOM elements. For example:

import { computeXPath } from 'compute-xpath';

const xPath = computeXPath(element)[0];

If you need to query the corresponding element or text based on xPath, you can call the browser API document.evalute. For example:

const result = document.evaluate(xPath, document.documentElement);
const element = result.iterateNext();

Parameters

  • node: The node to compute
  • optimized: Whether to optimize the XPath for the node. Does not imply the XPath is shorter; implies the XPath will be highly-scoped to the node.

License

BSD-3-Clause

Keywords

FAQs

Package last updated on 13 Sep 2024

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