Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dom-lib

rsuite394.8kMIT3.3.2TypeScript support: included

DOM helper library

dom-library, dom

readme

DOM helper library

CI NPM Version

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

Install

npm install dom-lib --save

Usage

import addClass from 'dom-lib/addClass';

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

API

Class

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

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

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

Query

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

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

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

changelog

3.0.1 (2021-12-16)

Bug Fixes

  • getContainer: container can be null (#27) (121ac6d)

3.0.0 (2021-11-02)

Bug Fixes

  • animation: remove webkitRequestAnimationFrame (#22) (69dbbb1)
  • deps: add @babel/runtime (#25) (b40f9e5)

Features

  • query: add support for isFocusable (#23) (eee920a)

2.1.0

  • feat(getPosition): support keep margin (#20)

2.0.2

  • Fix typescript type definition

2.0.1

  • fix: Update type definition

2.0.0

  • refactor: Migrate from flow to typescript

1.3.0

  • Add animation events helper

1.2.1

  • Add parameter enable3DTransform for translateDOMPositionXY

1.2.0

  • Added support for ESM

1.1.0

  • Support Server-side Rendering
  • Upgrade to Bebel 7

0.2.3

2017-06-26

  • Added WheelHandler
  • Added translateDOMPositionXY

0.2.1

  • Added throttle and debounce
  • Change space to 2

0.2.0

  • All changes to support es2015
  • Added test case

0.1.1

2017-03-31

  • Feature: Added support react 15.*