1.0.2 • Published 9 years ago

inject-markup v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

inject-markup Build Status

Inject HTML into a web page.

Install

Via npm:

$ npm install inject-markup --save

Via Bower:

$ bower install inject-markup --save

Usage

let fixture = `
<ul class='c-list'>
  <li>Lorem</li>
  <li>Ipsum</li>
</ul>
`;

injectMarkup(fixture);

console.log(document.body.innerHTML);

// <ul class='c-list'>
//   <li>Lorem</li>
//   <li>Ipsum</li>
// </ul>

API

injectMarkup(chunk, [options])

Returns the newly created element.

chunk

Type: string

HTML chunk to be injected into the web page.

options

root

Type: HTMLDocument
Default: document

Object representing the web page root.

container

Type: Node
Default: document.body

Container in which the fixture should be added to.

prefix

Type: string
Default: fixture-

Fixture prefix id.

Motivation

I was tired of writing this kind of module over and over again to help me with browser unit tests. So I've decided to move it to a module that now I can reuse.

License

MIT © Rafael Rinaldi