Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kvnneff/deku-component-mount
Mount a Deku component to the DOM
https://github.com/kvnneff/deku-component-mount
Last synced: about 1 month ago
JSON representation
Mount a Deku component to the DOM
- Host: GitHub
- URL: https://github.com/kvnneff/deku-component-mount
- Owner: kvnneff
- License: other
- Created: 2015-11-26T19:33:04.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-26T19:35:03.000Z (about 9 years ago)
- Last Synced: 2024-11-20T07:23:56.234Z (about 2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deku - deku-component-mount - Mount a Deku component into the DOM. (Testing)
README
# deku-component-mount [![Build Status](https://travis-ci.org/kvnneff/deku-component-mount.svg?branch=master)](https://travis-ci.org/kvnneff/deku-component-mount)
Mount a [Deku](https://github.com/dekujs/deku) component to the DOM to facilitate testing.
Code is originally by [Dominic Barnes](https://github.com/dominicbarnes/).
## Install
`npm install deku-component-mount`
## Example
```js
import assert from 'assert'
import mount from 'deku-component-mount'
import element from 'virtual-element'
import Mock from 'component-mock'const Component = {
render: function () {
return element('div', {id: 'hello-world'}, 'Hello World!')
}
}const node = Mock(Component).render()
const mountedNode = mount(node)assert(document.getElementById('hello-world')) //=> passes
mountedNode.unmount()
assert(document.getElementById('hello-world')) //=> fails
```## API
### mount(node)
Mount a Deku node to the DOM and return an object with a property `element` containing a reference to the rendered DOM element and a property `unmount` containing a function to remove the rendered DOM element from the DOM.
### mountedNode.unmount()
Remove the rendered element from the DOM
### mountedNode.element
A reference to the mounted dom element
## License
MIT