dom-magic
Simple ES6 utilities to manipulate DOM
Features
- JSX compatible, standalone
createElement
method (no react) - Show/hide elements
- Add event listeners
- Native ES6 module (requires babel/rollup to be used within browser)
Installation
$ npm install dom-magic --save$ yarn add dom-magic
ES6 Transpiler Setup
File: gulpfile.js
const _rollup_babel = ;const _rollup_resolve = ; _gulp;
File: babel.config.json
Examples
JSX Component
File: button.jsx
// Internal "ReactDOM"import * as React from 'dom-magic'; { // button css classes const classes = 'enlighter-btn'; // name set ? if propsname classes; // create button return <div = = > propstext||null </div>}
Transpiled JSX
createElement
is provided by dom-magic
{ // button css classes var classes = 'enlighter-btn'; // name set ? if propsname classes; // create button return ;}
Browser (abstract example)
var domMagic = ; // get target containervar targetEl = domMagic; // create elementvar buttonEl = ; // injectdomMagic;
Full Examples
License
dom-magic is OpenSource and licensed under the Terms of MPL 2.0 - your're welcome to contribute