1.1.5 • Published 3 years ago

dometizer v1.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

dometizer-logo

An easy way to create complex DOM elements with a lot of attributes using vanilla JS

npm version bundle size npm GitHub twitter

Getting Started

yarn add dometizer

Let's create a simple button element with custom class names and a custom data-attribute

import { create } from 'dometizer'

const myButton = create({
  type: 'button',
  className: ['button', 'button--primary'],
  'data-attribute': 'hello'
})

Methods

create

ArgumentDescriptionDefault
typeString: HTML Type of element to be createddiv
classNameArray: Classes to be added to HTMLElement[]
textString: Inner text to be added to the HTMLElementundefined
childrenArray: List of child elements of the DOM Element we are creating[]
import { create } from 'dometizer'

const myButton = create({
  type: 'button',
  className: ['button', 'button--primary'],
  'data-attribute': 'hello',
  id: 'my-button',
  text: 'Click Me!'
})

createFromSelector

ArgumentDescriptionDefault
selectorString: given selector to create an objectundefined
import { createFromSelector } from 'dometizer'

const button = createFromSelector('button#the-button.button.button--primary')

extend

ArgumentDescriptionDefault
classNameArray: Classes to be added to HTMLElement[]
textString: Inner text to be added to the HTMLElementundefined
childrenArray: List of child elements of the DOM Element we are creating[]
import { extend } from 'dometizer'

const extendedButton = extend(button, {
    text: 'Click Me!',
    className: ['button--primary'],
    'data-toggle': 'modal'
})

append

ArgumentDescriptionDefault
containerHTMLElement: Container element to append items
childrenArray: List of child elements of the DOM Element we are creating[]
import { append } from 'dometizer'

append(myElement, [the, child, elements])
1.1.5

3 years ago

1.1.3

3 years ago

1.1.2

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago