New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chi-create

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

chi-create

Simple utility to create DOM nodes

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

chi-create

NPM

Build Status Dependency Status

Selenium Test Status

DOM node creation ... now with added easy!

This module uses Node.js-style modules, for best results use browserify.

Examples

Create an empty <div> node and append it to the document body:

var create = require('chi-create');

var node = create('div');
document.body.appendChild(node);

Declare attributes on the node:

create('div', { "class": "test" });

Add text to the node (treats strings as text, not HTML):

create('div', 'Hello World');

Add existing DOM nodes (automatically detects DOM nodes):

var span = create('span', 'Hello World!');
create('div', span);

Add lots of nodes (can handle nested arrays and variadic arguments):

var children = [
    create('span', 'Hello '),
    create('span', 'World')
];

var mark = create('strong', '!');

create('div', children, mark);

Use them all together! Creates <div class="hello"><span>Hello</span> World<strong>!</strong></div>.

var hello = create('span', 'Hello'),
    mark = create('strong', '!'),
    attributes = { 'class': 'hello' };

create('span', attributes, hello, ' World', mark);

Reference

create(tagName, contents...);

tagName is the HTML tag name (e.g. 'div'). contents can be any number of arguments where each argument is either a plain object (for attributes), a string (for text), a DOM node (for adding existing DOM nodes), or an array that contains DOM nodes or more arrays.

FAQs

Package last updated on 03 Oct 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc