                     @emit 'close', this
                     @emit 'end'
                     @writable = false
+                    set_ready = =>
+                        @isready = yes
+                        @emit 'ready'
+                    if @builder?
+                        @builder.approve('ready', this, set_ready)
+                    else
+                        set_ready()
                 if @builder?
                     @builder.approve('end', this, close_tag)
                 else

            key # this should be a tag

    register: (type, checker) ->
        unless type is 'new' or type is 'end'
            throw new Error "only type 'new' or 'end' allowed."
        @checkers[type] ?= []
        @checkers[type].push checker

    approve: (type, parent, tag, callback) ->
        checkers = @checkers[type]?.slice?() ? []

        if type is 'new'
            next = (tag) ->
                checker = checkers.shift() ? callback
                checker(parent, tag, next)

        else if type is 'end'
            [callback, tag] = [tag, parent] # shift arguments
            next = (tag) ->
                checker = checkers.shift() ? callback
                checker(tag, next)
        else
            throw new Error "type '#{type}' not supported."
        # start
        next(tag)


        @buffer = [] # after this tag all children emitted data
        @pending = [] # no open child tag
        @parent = @builder
        @closed = no
        @writable = true
        @hidden = no
        @isready = no
        @isempty = yes
        @content = ""
        @children children, opts
