New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

select-dom

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

select-dom

Extra lightweight DOM selector helper

  • 4.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
185
increased by1.09%
Maintainers
1
Weekly downloads
 
Created
Source

select-dom gzipped size Travis build status npm version npm downloads

Lightweight querySelector/All wrapper that outputs an Array

Install

$ npm install select-dom

Examples

var select = require('select-dom')

/**
 * select()
 */
select('.foo a[href=bar]')
// => <Element>

select('.foo a[href=bar]', parentElement)
// => <Element>

/**
 * select.exists()
 */

select.exists('.foo a[href=bar]')
// => true/false

select.exists('.foo a[href=bar]', parentElement)
// => true/false


/**
 * select.all()
 */
select.all('.foo a[href=bar]')
// => [<Element>, <Element>, <Element>]

select.all('.foo a[href=bar]', parentElement)
// => [<Element>, <Element>, <Element>]

select.all('.foo a[href=bar]', [parentElement1, parentElement2])
// => [<Element>, <Element>, <Element>]

API

select(selector[, parent = document])

Maps to parent.querySelector(selector)

select.exists(selector[, parent = document])

Tests the existence of one or more elements matching the selector.

select.all(selector[, parents = document])

Maps to parents.querySelectorAll(selector) plus:

  • it always returns an array
  • parents can be undefined, an element, an array of elements, or NodeList

Essentially now you can do something like:

const parents = select.all('.parents');
if(checkSomething(parents)) {
    select.all('.foo a[href=bar]', parents);
}

Keywords

FAQs

Package last updated on 25 May 2018

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