 
     onattr: (el, key, value) ->
         return unless el.isempty
+        return unless el._stream_ready is yes
         console.warn "attributes of #{el.toString()} don't change anymore"
 
     onend: () ->
-        if @closed? and @opened_tags is 0
-            @close()
-        else
-            @builder.closed = 'pending'
-            @closed = @close
+        return @close() if @closed? or @opened_tags is 0
+        # delay until last tag gets closed and written out
+        @builder.closed = 'pending'
+        @closed = @close
 
 
 

        @emit 'entry', {job, order:(++@children)}

    release: () =>
        @emit 'release', {order:0} unless @released
        @released = yes



            @release() if @children
            @isnext = yes
        # get the order position of this entry
        idx = @parent?._stream.children ? -1
        # placeholder for close
        @parent?._stream.children++
        # when this entry is ready resume parent
        el.ready ->
            @parent?._stream.emit('close scope', order:idx+1)
        @parent?._stream.release()

    emit: ->
        @order.emit(arguments...)
