Huge News!Announcing our $40M Series B led by Abstract Ventures.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

  • 7.0.0-6
  • next
  • Source
  • npm
  • Socket score

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

select-dom npm downloads

Lightweight querySelector/All wrapper that outputs an Array

Version 5+ only supports browsers with Set support. If you need IE 10- support, stick to select-dom@4

Install

npm install select-dom
// This module is only offered as a ES Module
import select from 'select-dom';

API

Note: if a falsy value is passed as baseElement, you'll always get an empty result (bd578b9)

select(selector[, baseElement = document])

Maps to baseElement.querySelector(selector), except it returns undefined if it's not found

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

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

select('.non-existent', baseElement);
// => undefined

select.last(selector[, baseElement = document])

Like select(), except that it returns the last matching item on the page instead of the first one.

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

Tests the existence of one or more elements matching the selector. It's like select(), except it returns a boolean.

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

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

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

Maps to baseElements.querySelectorAll(selector) plus:

  • it always returns an array
  • baseElements can be a list of elements to query
select.all('.foo');
// => [<Element>, <Element>, <Element>]

select.all('.foo', baseElement);
// => [<Element>, <Element>, <Element>]

select.all('.foo', [baseElement1, baseElement2]);
// => [<Element>, <Element>, <Element>]
// This is similar to jQuery([baseElement1, baseElement2]).find('.foo')
  • delegate-it - DOM event delegation, in <1KB.
  • doma - Parse an HTML string into DocumentFragment or one Element, in a few bytes.
  • Refined GitHub - Uses this module.

Keywords

FAQs

Package last updated on 30 Dec 2020

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