Skip to content

Commit

Permalink
Add DOM html/text helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jun 8, 2016
1 parent 4a49892 commit a98ec50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ const dom = module.exports = {
return node
},

html(node, html) {
return (arguments.length > 1) ?
(node.innerHTML = html) : node.innerHTML.trim()
},

text(node, text) {
return (arguments.length > 1) ?
(node.textContent = text) : node.textContent.trim()
},

css(text) {
return assign(dom.element('style'), {
type: 'text/css', textContent: text
Expand Down
7 changes: 3 additions & 4 deletions static/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

{
const { name } = require('../package')
const { ready } = require('../lib/dom')
const { ready, html } = require('../lib/dom')
const v = process.versions

ready(() => {
document.body.innerHTML =
`${name} ${process.env.NODE_ENV} ${v.electron} / ${v.node}`

html(document.body,
`${name} ${process.env.NODE_ENV} ${v.electron} / ${v.node}`)
})
}

0 comments on commit a98ec50

Please sign in to comment.