3.0.0 • Published 4 years ago

@deleteagency/dom-helper v3.0.0

Weekly downloads
28
License
MIT
Repository
github
Last release
4 years ago

DOM Helper

Helps with common DOM tasks

Live Demo

Installation

Use the package manager npm for installation.

$ npm install @deleteagency/dom-helper

Usage

import {createFragment, createElement} from  '@deleteagency/dom-helper';

const fragment = createFragment('<li>option 1</li><li>option 2</li>');
const newElement = createElement('<a href="google.com">Go to Google</a>');

API

createFragment(htmlString)

Creates a new DocumentFragment based on the provided markup

htmlString

Required Type: String

DOMHelper.createElement(htmlString)

Creates a new Element based on the provided markup. If markup contains more then 1 sibling elements, only first will be returned. Returns null if markup contains zero valid elements.

htmlString

Required Type: String

querySelectorParent(target, selector, includeSelf = false)

Searches element up the DOM tree that matches provided selector

target

Required Type: Element

selector

Required Type: string

includeSelf

Optional Type: boolean

isElement(element)

Checks whether the passed value is an Element

element

Required Type: Object

createEvent(name)

Creates new Event ready for dispatching

name

Required Type: String

License

MIT

3.0.0

4 years ago

3.0.0-1

5 years ago

3.0.0-0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago