{"id":16019469,"url":"https://github.com/npkgz/dom-magic","last_synced_at":"2026-05-02T19:31:58.947Z","repository":{"id":57214702,"uuid":"248523721","full_name":"npkgz/dom-magic","owner":"npkgz","description":"simple ES6 utilities to manipulate browsers DOM","archived":false,"fork":false,"pushed_at":"2020-04-20T13:00:36.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T14:21:15.303Z","etag":null,"topics":["dom-manipulation","es6-javascript","es6-modules","jsx"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/dom-magic","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npkgz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-19T14:26:29.000Z","updated_at":"2021-05-24T12:15:02.000Z","dependencies_parsed_at":"2022-08-26T13:41:28.941Z","dependency_job_id":null,"html_url":"https://github.com/npkgz/dom-magic","commit_stats":null,"previous_names":["andidittrich/dom-magic"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/npkgz/dom-magic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fdom-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fdom-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fdom-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fdom-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npkgz","download_url":"https://codeload.github.com/npkgz/dom-magic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fdom-magic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dom-manipulation","es6-javascript","es6-modules","jsx"],"created_at":"2024-10-08T17:04:30.295Z","updated_at":"2026-05-02T19:31:58.929Z","avatar_url":"https://github.com/npkgz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"dom-magic\n=========================================\n\nSimple ES6 utilities to manipulate DOM\n\n## Features ##\n\n* JSX compatible, standalone `createElement` method (no react)\n* Show/hide elements\n* Add event listeners\n* Native ES6 module (requires babel/rollup to be used within browser)\n\n## Installation ##\n\n```bash\n$ npm install dom-magic --save\n$ yarn add dom-magic\n```\n\n### ES6 Transpiler Setup ###\n\nFile: `gulpfile.js`\n\n```js\n\nconst _rollup_babel = require('rollup-plugin-babel');\nconst _rollup_resolve = require('@rollup/plugin-node-resolve');\n\n_gulp.task('es6-transpile', async function(){\n    const bundle = await _rollup.rollup({\n        input: './src/browser/EnlighterJS.js',\n        plugins: [\n            _rollup_resolve(),\n            _rollup_babel()\n        ]\n    });\n\n    // write the bundle to disk\n    await bundle.write({\n        format: 'iife',\n        name: 'EnlighterJS',\n        file: './.tmp/enlighterjs.js'\n    });\n});\n```\n\nFile: `babel.config.json`\n\n```json\n{\n    \"plugins\": [\n        [\"@babel/plugin-transform-react-jsx\", {\n        }]\n    ],\n    \"presets\": [\n        [\n            \"@babel/preset-env\",\n            {\n                \"targets\": {\n                    \"browsers\": [\n                        \"safari \u003e= 7\",\n                        \"IE \u003e= 9\",\n                        \"ios \u003e= 9\",\n                        \"firefox \u003e= 50\",\n                        \"chrome \u003e= 50\",\n                        \"edge \u003e= 11\"\n                    ]\n                },\n                \"debug\": false\n            }\n        ]\n    ]\n}\n```\n\n## Examples ##\n\n### JSX Component ###\n\nFile: `button.jsx`\n\n```jsx\n// Internal \"ReactDOM\"\nimport * as React from 'dom-magic';\n\nexport function Button(props){\n\n    // button css classes\n    const classes = ['enlighter-btn'];\n\n    // name set ?\n    if (props.name){\n        classes.push('enlighter-btn-' + props.name);\n    }\n\n    // create button\n    return \u003cdiv \n            className={classes.join(' ')} \n            onClick={props.onClick}\n        \u003e\n            {props.text||null}\n        \u003c/div\u003e\n}\n```\n\n### Transpiled JSX ###\n\n`createElement` is provided by **dom-magic**\n\n```js\nfunction Button(props) {\n    // button css classes\n    var classes = ['enlighter-btn']; // name set ?\n\n    if (props.name) {\n    classes.push('enlighter-btn-' + props.name);\n    } // create button\n\n\n    return createElement(\"div\", {\n    className: classes.join(' '),\n    onClick: props.onClick\n    }, props.text || null);\n}\n```\n\n### Browser (abstract example) ###\n\n```js\nvar domMagic = require('dom-magic');\n\n// get target container\nvar targetEl = domMagic.getElement('#container-a');\n\n// create element\nvar buttonEl = Button({\n    text: \"hello world\",\n    name: \"test\"\n});\n\n// inject\ndomMagic.insertBefore(targetEl, buttonEl);\n```\n\n\n### Full Examples ###\n\n* [EnlighterJS](https://github.com/EnlighterJS/EnlighterJS)\n\n## License ##\n\ndom-magic is OpenSource and licensed under the Terms of [MPL 2.0](https://opensource.org/licenses/mpl-2.0) - your're welcome to contribute","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fdom-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpkgz%2Fdom-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fdom-magic/lists"}