 { EventEmitter } = require 'events'
 { deep_merge, indent, new_attrs, safe } = require './util'
-EVENTS = ['add', 'attr', 'attr:remove', 'text', 'remove']
+EVENTS = ['add', 'attr', 'attr:remove', 'text', 'remove', 'close']
 
 new_tag = (name, attrs, children, opts) ->
     unless typeof attrs is 'object'

                    return
            throw new Error("this shouldn't happen D:")
        return
    @emit 'add', tag
    return tag


            else
                data = "#{indent this}</#{@name}>"
                @closed = yes
            @emit 'close', this
            @emit 'end', data
        else if @closed is 'removed'
            @emit 'end'
