         unless content?
             return @content = @builder?.query 'text', this
         content = safe(content) if opts.escape
-        @write content, deep_merge(opts, escape:off) # dont double escape
         if opts.append
             @content += content
         else
             @content  = content
-        @emit('text', this, @content)
+        @emit('text', this, content)
+        @isempty = no
         this
 
     raw: (html, opts = {}) =>
-        @write html, deep_merge(opts, escape:off) # this is raw html, so no escape
         @emit('raw', this, html)
-        this
-
-    write: (content, {escape} = {}) =>
+        @isempty = no
+        this
+
+    write: (content, {escape, append} = {}) =>
         content = safe(content) if escape
-        return true if @hidden # dont emit data when this tag is hidden
-        if @isempty
-            @emit 'data', prettify this, "<#{@name}#{new_attrs @attrs}>"
-            @isempty = no
-        @emit 'data', prettify this, "#{content}" if content
+        @emit 'data', this, "#{content}" if content
+        if append ? yes
+            @content += content
+        else
+            @content  = content
+        @isempty = no
         true
 
     up: (opts = {}) =>

{ EventEmitter } = require 'events'
{ deep_merge, prettify, new_attrs, safe } = require './util'
EVENTS = ['add', 'attr', 'attr:remove', 'text', 'raw', 'show', 'hide', 'remove',
          'replace', 'close']



                if tag.pending.length
                    tag.pending[0].once 'end', on_end
                else
                    @pending = @pending.slice(1)
                    if @closed and @pending.length is 0
                        @end()
            else
                for known, i in @pending
                    if tag is known
                        @pending = @pending.slice(0,i).concat @pending.slice i+1
                        if @closed is 'pending'
                            @end()
                        return
                throw new Error("this shouldn't happen D:")
