Socket
Book a DemoInstallSign in
Socket

element-easy-builder

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-easy-builder

HTML Element Easy Builder

1.2.0
latest
npmnpm
Version published
Weekly downloads
49
-48.42%
Maintainers
1
Weekly downloads
 
Created
Source

HTML Element Easy Builder

Install

npm install element-easy-builder

Use

import { Element, renderElement } from 'element-easy-builder';

const el = new Element()
.attr('name', 'test')
.attr('del', false)
.attr('checked', true);

console.log(el.output());
{
  "type": "div",
  "attrs": {
    "checked": true,
    "name": "test"
  }
}
console.log(renderElement(el.output()));
<div checked name="test"/>

Children

const el2 = new Element().type("a").attr('href', 'http://github.com/yefei').append('YeFei Github');
el.append(el2);
el.append(new Element().type('img'));
console.log(renderElement(el.output(), 2));
<div name="test" checked class="aaa ccc">
  <a href="http://github.com/yefei">
    YeFei Github
  </a>
  <img/>
</div>

Class update

el.class('aaa', 'bbb'); // add aaa bbb
// output: class="aaa bbb"

el.class('ccc', { aaa: false, ddd: true }); // add ccc ddd, remove aaa
// output: class="aaa ccc ddd"

el.class(false); // remove all classes

Style update

el.style({ color: 'red' }); // add color
// output: style="color:red"

el.style({ color: undefined, backgroundColor: '#fff' }); // remove color, add background-color
// output: style="background-color:#fff"

el.style(false); // remove all style

FAQs

Package last updated on 28 Nov 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.