|
@ -20,6 +20,8 @@ jspm install create-node |
|
|
|
|
|
|
|
|
## Usage |
|
|
## Usage |
|
|
|
|
|
|
|
|
|
|
|
Passing in markup with one top level element will return an `HTMLElement` (or something that inherits from it e.g `HTMLDivElement`) |
|
|
|
|
|
|
|
|
```js |
|
|
```js |
|
|
import createNode from 'create-node'; |
|
|
import createNode from 'create-node'; |
|
|
|
|
|
|
|
@ -32,12 +34,28 @@ const markup = ` |
|
|
const node = createNode(markup); |
|
|
const node = createNode(markup); |
|
|
// HTMLDivElement |
|
|
// HTMLDivElement |
|
|
|
|
|
|
|
|
node.querySelector('span:last-child').textContent; |
|
|
node.querySelector('span:first-child').textContent; |
|
|
// 'world' |
|
|
// 'hello' |
|
|
|
|
|
|
|
|
document.body.appendChild(node); |
|
|
document.body.appendChild(node); |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
Passing in markup with multiple top level elements will return an `HTMLCollection` of `HTMLElement`s. |
|
|
|
|
|
|
|
|
|
|
|
```js |
|
|
|
|
|
import createNode from 'create-node'; |
|
|
|
|
|
|
|
|
|
|
|
const markup = ` |
|
|
|
|
|
<span>hello</span> |
|
|
|
|
|
<span>world</span>`; |
|
|
|
|
|
|
|
|
|
|
|
const collection = createNode(markup); |
|
|
|
|
|
// HTMLCollection |
|
|
|
|
|
|
|
|
|
|
|
collection.querySelector('span:last-child').textContent; |
|
|
|
|
|
// 'world' |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
## License |
|
|
## License |
|
|
|
|
|
|
|
|
MIT © Luke Childs |
|
|
MIT © Luke Childs |
|
|