This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@grebaldi/dom-ops

1.0.0 • Public • Published

dom-ops

functional dom operations

Installation

npm:

npm install --save @grebaldi/dom-ops

yarn:

yarn add @grebaldi/dom-ops

Usage

find

import {find} from '@grebaldi/dom-ops';

const allSectionsOnPage = find(document, 'section');
const allButtonsInSections = find(allSectionsOnPage, 'button');

Signature: find: (element: HTMLElement|[HTMLElement], selector: string) -> result: [HTMLElement]

Uses querySelectorAll internally, but converts the result into a regular Array.

findOne

import {findOne} from '@grebaldi/dom-ops';

const firstSectionOnPage = find(document, 'section');
const firstButtonInSection = find(firstSectionOnPage, 'button');

Signature: findOne: (element: HTMLElement|[HTMLElement], selector: string) -> result: HTMLElement

listen

import {findOne, listen} from '@grebaldi/dom-ops';

const button = findOne(document, 'button');

listen(button, 'click', () => alert('Button clicked!'));

Signature: listen: (element: HTMLElement|[HTMLElement], eventName: string, handler: function) -> unsubscribe: function

listenOnce

import {findOne, listenOnce} from '@grebaldi/dom-ops';

const button = findOne(document, 'button');

listenOnce(button, 'click', () => alert('Will fire just once!'));

Signature: listen: (element: HTMLElement|[HTMLElement], eventName: string, handler: function) -> unsubscribe: function

License

MIT, see LICENSE.md

Readme

Keywords

none

Package Sidebar

Install

npm i @grebaldi/dom-ops

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • _grebaldi