     if o.autogrow
       @once "focus", =>
         @initialHeight = @$().height()  unless @initialHeight
+        @initialWidth = @$().width()  unless @initialWidth
 
   setDomElement:(cssClass = "")->
     name = "name='#{@options.name}'"

    @valid = yes
    @inputCallback = null
    @previousHeight = null
    @setName options.name
    @setLabel()
    @setCallback()

        fontSize      : $input.css 'fontSize'
        fontWeight    : $input.css 'fontWeight'
        lineHeight    : $input.css 'lineHeight'
        whiteSpace    : if isVertical then 'pre-line' else 'pre'

    @on 'blur', => @_clone.detach()
    @on 'input', @bound 'resize'


  resize: (event) ->

    @_clone.appendTo 'body' unless document.body.contains @_clone[0]
    val = @getElement().value.replace(/\n/g,'\n&nbsp;')
    safeValue = Encoder.XSSEncode val
    @_clone.html safeValue

    { type } = @getOptions()

    if type.toLowerCase() is 'textarea'
    then return @_resizeVertically event
    else return @_resizeHorizontally event

  _getValue = (el, rule) -> parseInt el.css(rule), 10

  _resizeHorizontally: (event) ->

    return  unless @_clone

    width = @_clone.width()

    if @$().css('boxSizing') is 'border-box'
      padding = _getValue(@_clone, 'paddingLeft') + _getValue(@_clone, 'paddingRight')
      border  = _getValue(@_clone, 'borderLeftWidth') + _getValue(@_clone, 'borderRightWidth')
      width   = width + border + padding

    newWidth = if @initialWidth then Math.max @initialWidth, width else width

    if @previousWidth isnt newWidth
      @setWidth newWidth
      @emit 'InputWidthChanged'

    @previousWidth = newWidth


  _resizeVertically: (event) ->

    return  unless @_clone

    height = @_clone.height()

    if @$().css('boxSizing') is 'border-box'
      padding = _getValue(@_clone, 'paddingTop') + _getValue(@_clone, 'paddingBottom')
      border  = _getValue(@_clone, 'borderTopWidth') + _getValue(@_clone, 'borderBottomWidth')
      height  = height + border + padding

    newHeight = if @initialHeight then Math.max @initialHeight, height else height
