How to use the domutils.findAll function in domutils

To help you get started, we’ve selected a few domutils 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 jbhannah / amperize / lib / amperize.js View on Github external
if (!element.attribs.layout) {
                setLayoutAttribute(element);
            }
        }
    }



    // convert all of the img elements first so that we can perform lengthy
    // network requests in parallel before sequentially traversing the DOM
    if (self.config['amp-img']) {
        var imgTest = function(elem) {
            return elem.name === 'img' && elem.attribs.src;
        }
        var imgElems = domutils.findAll(elem => imgTest(elem), data);
        var imgTasks = imgElems.map(elem => amperizeImageElem(elem));
        await async.parallelLimit(imgTasks, 10);
    }

    // sequentially traverse the DOM
    async.reduce(data, html, function reduce(html, element, step) {
        var children;

        if (/(style|script|textarea|link)/.test(element.name)) {
            return step(null, html);
        }

        function close(error, html) {
            html += helpers.close(element);
            step(null, html);
        }