npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dodom

v3.1.2

Published

A simple minimalist class to manipulate DOM objects

Readme

DoDom npm downloads

A simple minimalist class to manipulate DOM objects

import DoDom from 'dodom';

let view = new DoDom('div', {
  class: 'view',
  attachToBody: true
});

let helloWorld = view.addDoDom('div', {
  text: 'Hello World!',
  styles: { fontStyle: 'italic', color: '#7777FF' }
});

view.addDoDom('div', {
  classes: ['button', 'pink'],
  text: 'Click me',
  onClick: () => {
    helloWorld.addText(' Bigger!');
  }
});

Installation

Using npm:

npm install dodom

Or download the DoDom.js file and place it somewhere in your project.

Usage

Using webpack:

import DoDom from 'dodom';
// or
const DoDom = require('dodom');

Using HTML's script tag:

<script src="path/DoDom.js"></script>

Modern browser ESM import is not supported out of the box, to keep the repo simple. If you want to use this way, download the DoDom.js file, open it, comment out the module.exports = DoDom; line and uncomment export default DoDom;. Then:

<script type="module">
  import DoDom from 'path/DoDom.js';
</script>

API

Constructor

new DoDom(type, options)
  • type: The type of DOM element to create (e.g., 'div', 'input') or an existing DOM element to wrap.
  • options: An object with the following optional properties:
    • class: A single CSS class to add.
    • classes: An array of CSS classes to add.
    • styles: An object of CSS styles to apply.
    • onClick: A function to execute on click/touch.
    • attachToBody: If true, appends the element to the document body.
    • parent: A parent DoDom instance to append this element to.
    • text: Text content for the element.
    • html: HTML content for the element.
    • visible: If false, hides the element.
    • name: A name for the DoDom instance.
    • children: An array of child DoDom instances to append.

Methods & Properties

Properties

  • dom: To access the original DOM element.
  • children: Array containing all DoDom children instances.
  • parent: DoDom parent (if any).
  • isDoDom: flag containing true.
  • name: the optional name value that was passed with the contructor.

Styling

  • setStyles(styles): Sets multiple CSS styles.
  • setStyle(key, value): Sets a single CSS style.
  • addClass(c): Adds a CSS class.
  • addClasses(classes): Adds multiple CSS classes.
  • removeClass(c): Removes a CSS class.
  • removeClasses(classes): Removes multiple CSS classes.

Content

  • setText(str): Sets the text content, removing all children.
  • addText(str): Appends text to the existing content.
  • addTextUp(str): Prepends text to the existing content.
  • setHTML(str): Sets the HTML content, removing all children.

Events

  • onClick(method): Adds a click event listener.

Adding children

  • addDoDom(type, options): Adds a child DoDom instance of the specified type.
  • addDomText(text, options): Adds a child DoDom instance with text content.
  • addDomHtml(html, options): Adds a child DoDom instance with HTML content.
  • addDomTexts(elements, options): Adds multiple inline text elements wrapped in a child DoDom instance.
  • addDomHtmls(elements, options): Adds multiple inline HTML elements wrapped in a child DoDom instance.

DOM Manipulation

  • appendChild(doDomChild): Appends a child DoDom instance.
  • prependChild(doDomChild): Prepends a child DoDom instance.
  • removeFromParent(): Removes the element from its parent.
  • attachToBody(): Appends the element to the document body.

Visibility

  • show(): Makes the element visible.
  • hide(): Hides the element.
  • setVisibility(shouldShow): Shows or hides the element based on the boolean value.

Utility

  • destroy(): Removes the element and its children from the DOM and marks it as destroyed.
  • destroyChildren(): Removes all child elements.
  • getChild(name): Retrieves a child DoDom instance by its name.
  • reflow(): Forces a reflow.