All files / src/helpers/markup getNodeListFromSelector.js

100% Statements 3/3
100% Branches 1/1
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                      5x 5x 5x    
import jsdom from "jsdom"
 
/**
 * This extract a NodeList using a Query Selector item as root
 *
 * @param {string} html
 * @param {object} node
 * @param {object} options
 * @return {NodeList} // A list of HTMLElement items that match the given Query Selector
 */
export default (html, node, options = {}) => {
  const dom = new jsdom.JSDOM(html, options)
  const doc = dom.window.document
  return doc.querySelectorAll(node.value)
}