How to use dom-serializer - 6 common examples

To help you get started, we’ve selected a few dom-serializer 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 wxajs / wxa / packages / wxa-cli / src / tester / domWalker.js View on Github external
let [, $1] = /bind(?::)?([\w]*)/g.exec(attr);
                if (!!~this.supportEvents.indexOf($1)) {
                    eventMap += `|${$1}:${attributes[attr]}`;
                    element.attribs[`bind${$1}`] = `$$e2e_${$1}`;
                }
            });

            eventMap = eventMap.replace(/^\|/, '');
            element.attribs['data-_wxaTestEventMap'] = eventMap;

            // generate unique id for tag.
            // pagePath + hash(parentNode + prevNode) + optional(class/id)
            let pagePath = path.relative(this.scheduler.wxaConfigs.context, path.dirname(this.mdl.src) + path.sep + path.basename(this.mdl.src, path.extname(this.mdl.src)));

            let ele = this.getParentAndPrevNode(element);
            let eleString = new Coder().decodeTemplate(domSerializer(ele, {xmlMode: true}));
            let hash= getHashWithString(eleString);

            let {isIeration, indexVariable} = this.findSelfOrAncestorIterationDirective(element);

            let keyElement = [pagePath, hash, element.attribs.id];
            if (isIeration) keyElement.push(`-{{${indexVariable}}}`);

            let id = this.assembleUniqueId(keyElement);
            element.attribs['data-_wxaTestUniqueId'] = id;
            element.attribs['class'] = this.dropSpace((element.attribs['class'] || '') + ' '+ id);
        }
    }
github wxajs / wxa / packages / wxa-cli / src / tester / domWalker.js View on Github external
parse(xml) {
        xml.forEach((element)=>this.walkXML(element));

        this.mdl.code = new Coder().decodeTemplate(domSerializer(xml, {xmlMode: true}));
    }
github TrySound / postcss-inline-svg / src / lib / apply-data.js View on Github external
data = data || {};
    const root = data.root || {};
    const selectors = data.selectors || {};

    assign(svg.attribs, root);

    Object.keys(selectors).forEach(selector => {
        const attribs = selectors[selector];
        const elements = selectAll(selector, svg);

        elements.forEach(element => {
            assign(element.attribs, attribs);
        });
    });

    return serialize(dom);
}
github substance / substance / util / cheerio.customized.js View on Github external
$._serialize = function(el) {
      var opts = el.options || (el.root && el.root.options)
      return serialize(el, opts)
    }
  }
github TrySound / postcss-inline-svg / src / render.js View on Github external
export default function render(code, ...processors) {
  const dom = parseDOM(code, { xmlMode: true });

  processors.forEach(processor => processor(dom));

  return serialize(dom);
}
github wxajs / wxa / packages / wxa-cli / src / resolvers / xml / index.js View on Github external
parse(mdl) {
        if (mdl.xml == null) return null;

        let libs = [];

        mdl.xml.forEach((element) => {
            libs = libs.concat(this.walkXML(element, mdl));
        });

        mdl.code = new Coder().decodeTemplate(domSerializer(mdl.xml, {xmlMode: true}));

        return libs;
    }

dom-serializer

render domhandler DOM nodes to a string

MIT
Latest version published 3 years ago

Package Health Score

82 / 100
Full package analysis

Popular dom-serializer functions