-#
-# Provides a wrapper around an +HTMLDocument+ to simplify interaction with it.
-#
-
 {Pathway} = require 'xpath'
 Colorizer = require 'util/Colorizer'
 inspect   = require 'util/inspect'

    # must be visible
    return true

  #
  # Determines whether the given node/xpath endpoint is visible.
  #
  # ==== Parameters
  # xpathOrNode<HTMLElement, Xpath>:: The thing to check for existence.
  # scope<HTMLElement>:: The element to scope the search to.
  #
  # @public
  #
  present: (xpathOrNode, scope) ->
    !!(@find xpathOrNode, scope)

  #
  # Generates a percentage match between the page and the xpaths based on
  # how many of the elements are present on the page.
  #
  # ==== Parameters
  # xpaths<Array[String, Pathway]>:: The xpaths to look for.
  #
  # ==== Returns
  # Number:: A number between 0 and 1 representing a percentage match.
  #
  # @public
  #
  match: (xpaths) ->
    match = 0
    for xpath in xpaths
      xpath = wesabe.xpath.from(xpath)
      match++ if @present xpath

    return match / xpaths.length

  #
  # Gets all the cells associated with the given node. For a <th> or <td> node,
  # that's all the <td> elements in the same column. For a <tr> node, that's
  # all the <td> elements in the same row.
  #
  # @param xpathOrNode [HTMLElement, Xpath]
  #   The thing to get related cells for.
  #
  # @return [tainted(Array[HTMLElement]), null]
  #   The cells related to +xpathOrNode+, or +null+ if the found node
  #   is not of a type that has related cells.
  #
  # @public
  #
  cells: (xpathOrNode) ->
    node = privacy.untaint @findStrict(xpathOrNode)
    name = node.tagName.toLowerCase()


      log.radioactive 'value=', value

      maxlength = element.getAttribute "maxlength"
      if value and maxlength
        maxlength = number.parse maxlength
        if maxlength
          log.warn "Truncating value to ", maxlength, " characters"
          value = value[0...maxlength]
