JSPM

dom-magic

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q31260F
  • License MPL-2.0

simple ES6 utilities to manipulate browsers DOM

Package Exports

  • dom-magic

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dom-magic) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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)

Install

$ npm install dom-magic --save
$ yarn add dom-magic

File: gulpfile.js

const _rollup_babel = require('rollup-plugin-babel');
const _rollup_resolve = require('@rollup/plugin-node-resolve');

_gulp.task('es6-transpile', async function(){
    const bundle = await _rollup.rollup({
        input: './src/browser/EnlighterJS.js',
        plugins: [
            _rollup_resolve(),
            _rollup_babel()
        ]
    });

    // write the bundle to disk
    await bundle.write({
        format: 'iife',
        name: 'EnlighterJS',
        file: './.tmp/enlighterjs.js'
    });
});

File: babel.config.json

{
    "plugins": [
        ["@babel/plugin-transform-react-jsx", {
        }]
    ],
    "presets": [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "browsers": [
                        "safari >= 7",
                        "IE >= 9",
                        "ios >= 9",
                        "firefox >= 50",
                        "chrome >= 50",
                        "edge >= 11"
                    ]
                },
                "debug": false
            }
        ]
    ]
}

Examples

License

dom-magic is OpenSource and licensed under the Terms of MPL 2.0 - your're welcome to contribute