 
 
 
-  outdated: (mutations) =>
+  outdated: (observedMutations) =>
     @observer.hold =>
-      for mutation in mutations
-        @appended(node, mutation.target) for node in mutation.addedNodes
-        @removed(node, mutation.target) for node in mutation.removedNodes
-        if mutation.type == 'characterData'
-          @update mutation.target
+      mutations = new Mutations(observedMutations)
+      switch mutations.status()
+        when 'appended' then @appended(mutations)
+        when 'updated' then @updated(mutations)
+        when 'removed' then @removed(mutations)
 
     event = new CustomEvent('Editor:updated', {bubbles: true})
     @element().dispatchEvent(event)

        offset = 0
      else
        offset = @lineOffset(line, sel.focusNode, sel.focusOffset)
        
      cursor = new Editor.Cursor(offset)

      lines = @parse(@cloneNodesFrom(line))

      @fragment.appendChild(node)


class Mutations
  constructor: (mutations) ->
    @removed = []
    @appended = []
    @updated = []

    for mutation in mutations
      @setTarget(mutation.target)
      if mutation.addedNodes.length > 0
        @appended.push mutation.target
      else if mutation.type == 'characterData'
        @updated.push mutation.target
      else
        @removed.push mutation.target

  setTarget: (target) ->
    return unless target.parentElement?
    if @target? && @target.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_FOLLOWING
      @target = target
    else
      @target = target

  status: =>
    if @appended.length > 0
      "appended"
    else if @updated.length > 0
      'updated'
    else if @removed.length > 0
      'removed'
    else
      'none'

Editor.Parsers = []
Editor.Extensions = []
