 
         '' # strip suffix from original name
 
-    childDom = dom.ownerDocument.createElement(elementName or 'div')
+    childDom = @$tubularHtmlCursor().ownerDocument.createElement(elementName or 'div')
 
     if elementId isnt null # still trigger for empty ID string
       childDom.setAttribute 'id', elementId

      if currentCondition isnt condition
        if condition
          # forking the original view-model, since this one is based around the condition model value
          self.fork { currentDom: @currentDom, currentTrailer: endNode }, subTemplate
        else
          while startNode.nextSibling isnt endNode
            startNode.parentNode.removeChild startNode.nextSibling # @todo optimize using local vars


# @todo obviously encapsulate
createState = (dom, trailer) ->
  # the state is a closure that normally returns the current context DOM, or inserts a child node if one is given
  (node) ->
    if node
      if trailer then dom.insertBefore(node, trailer) else dom.appendChild(node)
    else
      dom

window.tubularHtml =
  # @todo get the container from somewhere
  $tubularHtmlCursor: createState document.getElementById('container')

  element: (options...) ->
    subTemplate = null

    elementName = null
