Skip to content

Commit

Permalink
Simplify css helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jan 14, 2016
1 parent 13975dd commit 0bd60c4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/dom.js
@@ -1,33 +1,31 @@
'use strict'

const { assign } = Object

const dom =
module.exports = {

$: document.querySelector.bind(document),

$$: document.querySelectorAll.bind(document),

ready: (fn) => {
if (document.readyState !== 'loading') fn()
else dom.once(document, 'DOMContentLoaded', fn)
},

css(text) {
let node = document.createElement('style')

node.type = 'text/css'
node.textContent = text
element: document.createElement.bind(document),

return node
css(text) {
return assign(dom.element('style'), {
type: 'text/css', textContent: text
})
},

stylesheet(url) {
let node = document.createElement('link')

node.rel = 'stylesheet'
node.type = 'text/css'
node.href = url

return node
stylesheet(href) {
return assign(dom.element('link'), {
rel: 'stylesheet', type: 'text', href
})
},

append(node, to) {
Expand Down

0 comments on commit 0bd60c4

Please sign in to comment.