Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pnodet/help-dom
Small js package I use to help me deal with the dom
https://github.com/pnodet/help-dom
dom javascript npm-package
Last synced: 23 days ago
JSON representation
Small js package I use to help me deal with the dom
- Host: GitHub
- URL: https://github.com/pnodet/help-dom
- Owner: pnodet
- License: mit
- Created: 2021-08-28T23:36:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-26T20:21:05.000Z (over 3 years ago)
- Last Synced: 2025-01-06T22:58:33.209Z (about 1 month ago)
- Topics: dom, javascript, npm-package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/help-dom
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# help-dom
> Small js package I use to help me deal with the dom[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
[![GitHub workflow status](https://img.shields.io/github/workflow/status/pnxdxt/help-dom/CI)](https://github.com/pnxdxt/help-dom)
[![npm bundle size](https://img.shields.io/bundlephobia/min/help-dom)](https://bundlephobia.com/package/help-dom)
[![npm downloads](https://img.shields.io/npm/dt/help-dom)](https://www.npmjs.com/package/help-dom)## Install
```
$ npm install help-dom
```
## ImportThis package is pure [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). It cannot be `require()`'d from CommonJS.
Use `import foo from 'foo'` instead of `const foo = require('foo')` to import the package.
```js
// Load entire build
import * as helpDom from 'help-dom';// Load by method
import {main} from 'help-dom';
```
If the package is used in an async context, you could use [`await import(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports) from CommonJS instead of `require(…)`.**You also need to make sure you're on the latest minor version of Node.js. At minimum Node.js 12.20, 14.14, or 16.0.**
Read more here: [sindresorhus/esm-package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
## Usage
```js
main([1,2,3], (element) => typeof element === 'string');
//=> falsemain(['1', '2', '3'], (element) => typeof element === 'string');
//=> true
```## API
`allElements(selector)` : Select all elements matching given `selector`.
`appendTo(element, target)`
`prependTo(element, target)`
`attsToString`
`classPresentIf` : Add/remove a given class if condition is true/false.
`createElement` : Create a single DOM element.
`createElementsArray` : Create an array of DOM elements from given html.
`getAttributes` : Get attributes of `element` as an object with key/value.
`getBoundingClientRect` :
`getCookie` : Get the value of a cookie.
`getImageSizeByUrl`
`getIndex` : Returns the index of a `node` in a `nodeList`.
`getLocalStorage2` :
`getOffset` :
`getOffsetParent` :
`getParentByData` :
`getParentById` :
`getPosition` :
`getPositionFromOffset` :
`getScroll` :
`getSessionStorage2` :
`getUserLanguage` :
`getViewportPosition` :
`glb` :
`id` :
`insertAfter` :
`insertBefore` :
`isWebComponent` :
`makeStorageHelper` :
`nextChild` :
`objectifyForm` :
`offDOM` :
`onDOM` :
`onDOMMany` :
`removeElements` :
`serialize` :
`setCaretPosition` :
`setContent` :
`store` :
`tag` :
`toClipboard` :
`toClipboardFromElement` :
`windowLoaded` :
## License
MIT © [Paul Nodet](https://pnodet.com)