You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Luke Childs
4ae97b9aa3
|
8 years ago | |
---|---|---|
src | 9 years ago | |
test | 9 years ago | |
.gitignore | 9 years ago | |
.npmignore | 9 years ago | |
.travis.yml | 9 years ago | |
README.md | 8 years ago | |
package.json | 8 years ago |
README.md
create-node
Converts an HTML string to a DOM node.
❗️Important note
This module is intended for use in the browser and therefore requires a JS environment that implements the DOM. If you want to use it with node you'll also need
node-browser-environment
or some other browser environment polyfill.
Install
npm install --save create-node
or
jspm install create-node
Usage
import createNode from 'create-node';
const markup = `
<div>
<span>hello</span>
<span>world</span>
</div>`;
const node = createNode(markup);
// HTMLDivElement
node.querySelector('span:last-child').textContent;
// 'world'
document.body.appendChild(node);
License
MIT © Luke Childs