New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

domweaver

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domweaver

Vanilla JavaScript Class component for modular DOM element creation.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

domweaver

use bp as the generic Element object blueprint

import bp from './element-blueprint';

call bp with element type and class name as arguemnts

const newDiv = bp('div', 'first-div');

Call additional methods on the object:

Add more attributes

newDiv.addAttributes({
  id: 'main-div',
  value: '23',
});

Append event listener

newDiv.addEventListener('Click', (e) => function());

Add child div with the new element as an argument

newDiv.addChild(
  bp('img', 'hero-img').addAttributes({
    src: 'img url here',
    alt: 'The Main Thing',
  })
);

Add Text to the element

newDiv.addText('Main Text Content');

And finally, call the recursive build function on the tail end to build all elements and their children

newDiv
  .addChild(bp('div', 'first-child').addChild(bp('div', 'grand-child')))
  .build();

FAQs

Package last updated on 25 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts