Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eldoy/sord
Microscopic replacement for 'document.querySelector' and 'document.querySelectorAll'
https://github.com/eldoy/sord
Last synced: 6 days ago
JSON representation
Microscopic replacement for 'document.querySelector' and 'document.querySelectorAll'
- Host: GitHub
- URL: https://github.com/eldoy/sord
- Owner: eldoy
- Created: 2019-10-25T04:01:51.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-25T11:06:02.000Z (about 5 years ago)
- Last Synced: 2024-01-01T15:03:23.110Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SORD
Microscopic replacement for `document.querySelector` and `document.querySelectorAll`.Only 182 bytes minified.
### Install
In Node.js:
`npm i sord`In the browser:
```html
function s(a,b,c,x,y,z,f,i){if(typeof a=='object'){x=a;y=b}else{x=document.body;y=a}z=x.querySelectorAll(y);if(f=typeof b=='function'?b:c)for(i=0;i<z.length;)f(z[i++],x);return z[0]}
```### Usage
```javascript
// From module
var s = require('sord')// Find HTML element
s('#app')// Find element inside el
s(el, 'input')// Use callback instead of querySelectorAll
s('p', el => el.textContent = 'hello')// Callback with root, default root is document.body
s(document, 'p', (el, root) => {
el.textContent = 'hello'
root.style.opacity = 0.5
})
```
ISC licensed. Enjoy!