create-node
Converts an HTML string to a DOM node
Last updated 4 years ago by lukechilds .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install create-node 
SYNC missed versions from official npm registry.

create-node

Converts an HTML string to a DOM node.

Build Status Coverage Status npm

Install

npm install --save create-node

or

jspm install create-node

Usage

Passing in markup with one top level element will return an HTMLElement (or something that inherits from it e.g HTMLDivElement)

import createNode from 'create-node';

const markup = `
<div>
  <span>hello</span>
  <span>world</span>
</div>`;

const node = createNode(markup);
// HTMLDivElement

node.querySelector('span:first-child').textContent;
// 'hello'

document.body.appendChild(node);

Passing in markup with multiple top level elements will return an HTMLCollection of HTMLElements.

import createNode from 'create-node';

const markup = `
<span>hello</span>
<span>world</span>`;

const collection = createNode(markup);
// HTMLCollection

collection[1].textContent;
// 'world'

License

MIT © Luke Childs

Current Tags

  • 2.0.3                                ...           latest (4 years ago)

10 Versions

  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 2
Last Month 1
Dependencies (0)
None
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |