# dom-lib

> DOM helper library

Latest version **3.3.2** (published 2024-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install dom-lib
pnpm add dom-lib
yarn add dom-lib
bun add dom-lib
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.2 |
| Published | 2024-09-22 |
| First published | 2016-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 167 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Simon Guo |
| Maintainers | simonguo |
| Keywords | dom-library, dom |

## Links

- npm: https://www.npmjs.com/package/dom-lib
- Repository: https://git@github.com/rsuite/dom-lib
- Homepage: https://github.com/rsuite/dom-lib#readme
- Issues: https://github.com/rsuite/dom-lib/issues
- npm.io page: https://npm.io/package/dom-lib

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.20.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 3.3.2 (latest) — 2024-09-22
- 3.1.0-canary.1 (canary) — 2021-11-11
- 1.0.0-beta.1 (beta) — 2018-03-23
- 3.3.1 — 2024-02-29
- 3.3.0 — 2024-02-28
- 3.2.0 — 2024-01-11
- 3.1.6 — 2023-01-29
- 3.1.5 — 2022-11-11
- 3.1.4 — 2022-11-08
- 3.1.3 — 2022-09-28
- 3.1.2 — 2022-02-10
- 3.1.1 — 2022-02-10
- 3.1.0 — 2022-02-10
- 3.0.1 — 2021-12-16
- 3.1.0-canary — 2021-11-11
- … 41 more at https://npm.io/package/dom-lib/versions

## README

# DOM helper library

[![CI](https://github.com/rsuite/dom-lib/workflows/Node.js%20CI/badge.svg)](https://github.com/rsuite/dom-lib/actions)
[![NPM Version](https://img.shields.io/npm/v/dom-lib?color=33cd56&logo=npm)](https://www.npmjs.com/package/dom-lib)

Click the "Exports" link in the sidebar to see a complete list of everything in the package.

## Install

```
npm install dom-lib --save
```

## Usage

```js
import addClass from 'dom-lib/addClass';

addClass(element, 'foo');
// output: <div class="foo"></div>
```

## API

Class

```typescript
hasClass: (node: Element, className: string) => boolean;
addClass: (node: Element, className: string) => Element;
removeClass: (node: Element, className: string) => Element;
toggleClass: (node: Element, className: string) => Element;
```

Style

```typescript
getStyle: (node: Element, property: string) => string;
getStyle: (node: Element) => Object;

removeStyle: (node: Element, property: string) => void;
removeStyle: (node: Element, propertys: Array<string>) => void;

addStyle: (node: Element, property: string, value: string) => void;
addStyle: (node: Element, style: Object) => void;
```

Events

```typescript
on: (target: Element, eventName: string, listener: Function, capture: boolean = false) => {
  off: Function;
};
off: (target: Element, eventName: string, listener: Function, capture: boolean = false) =>
  void;
```

Query

```typescript
activeElement: () => Element;
getHeight: (node: Element, client: Element) => number;
getWidth: (node: Element, client: Element) => number;
getOffset: (node: Element) => Object;
getOffsetParent: (node: Element) => Object;
getPosition: (node: Element, offsetParent) => Object;
getWindow: (node: Element) => String;
nodeName: (node: Element) => String;
ownerDocument: (node: Element) => Object;
ownerWindow: (node: Element) => Object;
contains: (context: Element, node: Element) => boolean;
scrollLeft: (node: Element) => number;
scrollTop: (node: Element) => number;
isFocusable: (node: Element) => boolean;
```

Utils

```typescript
scrollLeft: (node: Element)=> number;
scrollLeft: (node: Element, val: number)=> void;

scrollTop: (node: Element)=> number;
scrollTop: (node: Element, val: number) => void;
```

---
_Source: https://npm.io/package/dom-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
