Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benjaminreid/dom
dom aims to be a small and simple module to interact with the DOM.
https://github.com/benjaminreid/dom
Last synced: 3 days ago
JSON representation
dom aims to be a small and simple module to interact with the DOM.
- Host: GitHub
- URL: https://github.com/benjaminreid/dom
- Owner: benjaminreid
- License: mit
- Created: 2020-02-13T16:18:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T07:15:44.000Z (about 2 years ago)
- Last Synced: 2025-01-02T21:39:07.607Z (6 days ago)
- Language: TypeScript
- Homepage:
- Size: 1.17 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# dom [![Build Status](https://travis-ci.org/benjaminreid/dom.svg?branch=master)](https://travis-ci.org/benjaminreid/dom) ![File Size](https://img.badgesize.io/benjaminreid/dom/master/src/index.ts?compression=gzip)
`dom` aims to be a small and simple module to interact with the DOM. It has a
tiny footprint and comes with support for TypeScript. It won’t brew you a coffee
any time soon but it may save you a few keystrokes.## Installing
Install with your package manager of choice.
```
yarn add @benjaminreid/dom
``````
npm install @benjaminreid/dom
```## Usage
```js
import { $, $$ } from "@benjaminreid/dom";// a wrapper around document.querySelector
const $element = $("#button");// a wrapper around document.querySelectorAll
const $elements = $$(".button");// except you’ll get an Array back, not a NodeList
$elements.map($element => $element.innerText);// $ and $$ take a second argument so you can select an element withing another
const $parent = $("#parent");
const $children = $$(".children", $parent);
```## Tests
`dom` is fully tested with [Jest](https://jestjs.io/) and
[Testing Library](https://testing-library.com/). You can run them yourself
with...```
yarn test
``````
npm test
```## Contributing
Pull requests are very much welcome. If you have some useful DOM related
functions which you’ve been copying from project to project like me and think
they might be at home here, please post your ideas.