 doc = @document
 
 
+ELEMENT_NODE = 1
+TEXT_NODE = 3
+
+
 isElement = (el) ->
-  el?.nodeType and el.nodeType is doc.ELEMENT_NODE
+  el?.nodeType and el.nodeType is ELEMENT_NODE
 
 
 isText = (el) ->
-  el?.nodeType and el.nodeType is doc.TEXT_NODE
+  el?.nodeType and el.nodeType is TEXT_NODE
 
 
 merge = (left, right) ->

  doc.createTextNode(text)


directAttributes =
  'className': 'className'
  'id': 'id'
  'html': 'innerHTML'
  'text': 'textContent'
  'value': 'value'



        el.setAttribute(attr, value)
      else
        if attr is 'html' and typeof value isnt 'string'
          el.removeChild(el.lastChild) while el.lastChild
          if isElement(value)
            el.appendChild(value)
          else if value instanceof Array
            exports.appendChildren(el, value)
        else if attr is 'text' and isText(el)
          el.nodeValue = value
        else
          el[directAttr] = value
  null


class SafeString extends exports.Element
