Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 337 Bytes

$x-implementation.md

File metadata and controls

22 lines (18 loc) · 337 Bytes

$x 콘솔 유틸리티 구현

function $x(xpath) {
  const elements = document.evaluate(
    xpath,
    document,
    null,
    XPathResult.ANY_TYPE,
    null
  );

  const nodes = [];

  let node = null;
  while ((node = result.iterateNext())) {
    nodes.push(node);
  }

  return nodes;
}