code: function (writer, filter) {
              var self = this, tmp, attrName, tagName = self.tagName;    // special treat for doctype
              // special treat for doctype
              if (tagName === '!doctype') {
                  writer.append(this.toHtml() + '\n');
                  return;
              }
              self.__filter = filter;
              self.isChildrenFiltered = 0;    // process its open tag
              // process its open tag
              if (filter) {
                  // element filtered by its name directly
                  if (!(tagName = filter.onTagName(tagName))) {
                      return;
                  }
                  self.tagName = tagName;
                  tmp = filter.onTag(self);
                  if (tmp === false) {
                      return;
                  }    // replaced
                  // replaced
                  if (tmp) {
                      self = tmp;
                  }    // replaced by other type of node
                  // replaced by other type of node
                  if (self.nodeType !== 1) {
                      self.writeHtml(writer, filter);
                      return;
                  }    // preserve children but delete itself
                  // preserve children but delete itself
                  if (!self.tagName) {
                      self._writeChildrenHTML(writer);
                      return;
                  }
              }
              writer.openTag(self);    // process its attributes
              // process its attributes
              var attributes = self.attributes;
              for (var i = 0; i < attributes.length; i++) {
                  var attr = attributes[i];
                  attrName = attr.name;
                  if (filter) {
                      // filtered directly by name
                      if (!(attrName = filter.onAttributeName(attrName, self))) {
                          continue;
                      }
                      attr.name = attrName;    // filtered by value and node
                      // filtered by value and node
                      if (filter.onAttribute(attr, self) === false) {
                          continue;
                      }
                  }
                  writer.attribute(attr, self);
              }    // close its open tag
              // close its open tag
              writer.openTagClose(self);
              if (!self.isSelfClosed) {
                  self._writeChildrenHTML(writer);    // process its close tag
                  // process its close tag
                  writer.closeTag(self);
              }
          }
docs: serialize tag to html string in writer
  @param writer
  @param filter