 
       if delta.attributes?
         for attr in delta.attributes
-          @setAttr(selection.clone().attr = attr)
+          @setAttr(selection.clone().style = attr)
 
 if window?
   window.Rte = Rte

  deleteSel: (sel) ->
    if not sel.isValid()
      throw new Error "Invalid selection"
    if not 0 <= sel.startPos.loc <= @_rte.words[sel.startPos.word].length
      throw new Error "Invalid selection"
    if not 0 <= sel.endPos.loc <= @_rte.words[sel.endPos.word].length
      throw new Error "Invalid selection"

    s = sel.startPos.word
    e = sel.endPos.word

    newLeft = @_rte.words[s].substring(0, sel.startPos.pos)
    newRight = @_rte.words[e].substring(sel.endPos.pos)

    if s == e
      @_rte.words[s] = newLeft + newRight

      # delete the words in between
      @deleteWords(s+1, e)
    else
      @_rte.words[s] = newLeft
      @_rte.words[e] = newRight

      # delete the words in between
      @deleteWords(s+1, e)

  overlaps: (s) ->
    @startPos.lt(s.endPos) or @endPos.gt(s.startPos)

  #TODO
  setStyle: (@style) ->

  clone: ->
    new Selection(@startPos, @endPos)
