     'attr','text', 'raw', 'data'
 ]
 
-# TODO drainage
 # TODO dont emit data from hidden tags
 
 
 class Entry
-    constructor: (el, @parent) ->
+    constructor: (@stream, el, @parent) ->
         @order = new OrderedEmitter span:yes
         # states
         @released = no
-        @isnext = no
+        @isnext = if @parent? then no else yes
         @children = 0 # we start with 1 to use 0 as pause bit
         # just run the job when it got ready
-        @order.on('entry', ({job}) -> job?())
+        @order.on('entry', @do_job)
+        return if @isnext
         # tell the parent to write this entry when its time
         @parent?._stream.write =>
             @release() if not el.isempty or el.closed is yes

            @template.on(event, this["on#{event}"].bind(this))

    write: (data) ->
        @stream.emit('data', data) if data

    close: () =>
        @builder.closed = yes
        @stream.emit 'end'

    # eventlisteners


        unless parent.writable
            console.warn "creating #{el.toString()} in closed #{parent.toString()} omitted"
            return
        el._stream = new Entry this, el, parent
        @opened_tags++
        el._stream.write =>
            return if el is el.builder
