Serialize tag

@inner
@param {Object} elem the tag to serialize
@param {Object} opts the serialize options
@return {string}
function serializeTag(elem, opts) {
    // Handle SVG
    if (elem.name === 'svg') {
        opts = {decodeEntities: opts.decodeEntities, xmlMode: true};
    }

    let tag = '<' + elem.name;
    let attribs = serializeAttrs(elem.attribs, opts);

    if (attribs) {
        tag += ' ' + attribs;
    }

    let closeAllTag = opts.xmlMode;
    let isSingleTag = singleTag[elem.name];
    let hasChildren = elem.children && elem.children.length;
    let endTag = '</' + elem.name + '>';
    if (hasChildren) {
        tag += '>';
        tag += serializeDom(elem.children, opts);
        tag += endTag;
    }
    else if (closeAllTag || !isSingleTag) {
        if (isSingleTag || elem.isSelfClose) {
            tag += '/>';
        }
        else {
            tag += '>' + endTag;
        }
    }
    else {
        tag += '>';
    }

    return tag;
}