   else
     return null
 ###
-      
+
 
 # Form elements collection should allow retrieving individual element by its
 # name, e.g. form.elements["username"] => <input name="username">

# Fix things that JSDOM doesn't do quite right.


HTML          = require("jsdom").dom.level3.html


HTML.HTMLElement.prototype.__defineGetter__ "offsetLeft",   -> 0

    @_version = @_element._version
  return @_snapshot


# For some reason HTML5 uses elementBuilder instead of createElement
HTML5.TreeBuilder.prototype.createElement = (name, attributes, namespace)->
  el = this.document.createElement(name)
  el.namespace = namespace
  if(attributes)
    if(attributes.item)
      for i in [0...attributes.length]
        this.copyAttributeToElement(el, attributes.item(i))
    else
      for i in [0...attributes.length]
        this.copyAttributeToElement(el, attributes[i])
  return el