
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
selector-lite
Advanced tools
DEPRECATED! It is merged into dom-lite! A small pure-JavaScript CSS selector engine
require('dom-lite/selector')A small pure-JavaScript CSS selector engine.
var selector = require("selector-lite")
// Can be used to implement browser built-in functions.
function getElementById(id) {
return selector.find(this, "#" + id, true)
}
function getElementsByTagName(tag) {
return selector.find(this, tag)
}
function getElementsByClassName(sel) {
return selector.find(this, "." + sel.replace(/\s+/g, "."))
}
function querySelector(sel) {
return selector.find(this, sel, true)
}
function querySelectorAll(sel) {
return selector.find(this, sel)
}
find(node, selector, returnFirstMatch) - Find matching elements like querySelector.matches(node, selector) - Returns a Boolean indicating whether or not
the element would be selected by the specified selector string.closest(selector) - Returns the Element, descendant of this element
(or this element itself), that is the closest ancestor of the elements
selected by the selectors given in parameter.next(selector) - Retrieves the next sibling that matches selector.prev(selector) - Retrieves the preceding sibling that matches selector.Custom selector can be added to selector.selectorMap, where method shortcuts are available (m->matches, c->closest, n->next, p->prev).
_ - node.v - part between () in :nth-child(2n+1).a and b can be used as temp variables.// Add `:input` selector
selector.selectorMap.input = "_.tagName=='INPUT'"
// Add `:val()` selector
selector.selectorMap.val = "_.value==v"
Follow Coding Style Guidelines
Run tests
npm install
npm test
GitHub repo |
npm package |
DOM spec |
Selectors Level 3 |
Coveralls coverage
Buy Me A Tea
Copyright (c) 2015-2021 Lauri Rooden <lauri@rooden.ee>
The MIT License
FAQs
DEPRECATED! It is merged into dom-lite! A small pure-JavaScript CSS selector engine
We found that selector-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.