How to use the htmlparser2.ElementType.isTag function in htmlparser2

To help you get started, we’ve selected a few htmlparser2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / okam / packages / okam-build / lib / processor / template / serializer / index.js View on Github external
function serializeDom(dom, opts) {
    if (!Array.isArray(dom)) {
        dom = [dom];
    }

    opts = opts || {};

    let output = '';
    for (let i = 0, len = dom.length; i < len; i++) {
        let elem = dom[i];

        if (elem.type === 'root') {
            output += serializeDom(elem.children, opts);
        }
        else if (ElementType.isTag(elem)) {
            output += serializeTag(elem, opts);
        }
        else if (elem.type === ElementType.Directive) {
            output += serializeDirective(elem);
        }
        else if (elem.type === ElementType.Comment) {
            output += serializeComment(elem);
        }
        else if (elem.type === ElementType.CDATA) {
            output += serializeCDATA(elem);
        }
        else {
            output += serializeText(elem, opts);
        }
    }