How to use the domutils.findOne 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 Janpot / microdata-node / lib / microdataDom.js View on Github external
module.exports = function (dom, config) {
  config = config || {};

  // resolve the base url of the document
  var base = config.base || '';
  var baseElem = DOM.findOne(function (elem) {
    return elem.name === 'base' && DOM.hasAttrib(elem, 'href');
  }, dom);
  if (baseElem) {
    base = urlUtil.resolve(base, baseElem.attribs.href);
  }

  var strict = config.strict;

  var idMap = mapIds(dom);

  function _getItems (nodes, isTopLevel) {
    var items = [];
    nodes.forEach(function (node) {
      var childIsTopLEvel = isTopLevel;
      var isStrictItem = isItem(node) && !isProperty(node);
      var isNonStrictItem = isItem(node) && isTopLevel;