Skip to content

Instantly share code, notes, and snippets.

@bdchauvette
Created December 13, 2016 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdchauvette/bc9205a33538e025f1e503dc0211b171 to your computer and use it in GitHub Desktop.
Save bdchauvette/bc9205a33538e025f1e503dc0211b171 to your computer and use it in GitHub Desktop.
mithril-node-render: components with children
global.window = require('mithril/test-utils/browserMock')()
global.document = window.document
const m = require('mithril')
const o = require('mithril/ospec/ospec')
const renderToString = require('mithril-node-render')
const ParentComponent = {
view(node) {
return m('div', node.children)
}
}
// =============================================================================
o('html tag', () => {
// Normal divs works fine
o(renderToString(m('div', 'howdy'))).equals('<div>howdy</div>')
o(renderToString(m('div', m('span', 'howdy')))).equals('<div><span>howdy</span></div>')
})
o('parent component', () => {
// But components don't
o(renderToString(m(ParentComponent, 'howdy'))).equals('<div>howdy</div>')
o(renderToString(m(ParentComponent, m('span', 'howdy')))).equals('<div><span>howdy</span></div>')
})
o.run()
{
"dependencies": {
"mithril": "https://github.com/lhorie/mithril.js/tarball/rewrite",
"mithril-node-render": "^1.0.1-3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment