Sha256: 768035687cac0d246e0f65c6721513badf9c87dd21a8b7abaa0acbf92311afdd

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const conversions = require("webidl-conversions");

exports.FILTER_ACCEPT = 1; // NodeFilter.FILTER_ACCEPT
exports.FILTER_REJECT = 2; // NodeFilter.FILTER_REJECT
exports.FILTER_SKIP = 3; // NodeFilter.FILTER_SKIP

exports.filter = (nodeIteratorOrTreeWalkerImpl, nodeImpl) => {
  if (nodeIteratorOrTreeWalkerImpl._active) {
    throw DOMException.create(nodeIteratorOrTreeWalkerImpl._globalObject, [
      "Recursive node filtering",
      "InvalidStateError"
    ]);
  }

  const n = nodeImpl.nodeType - 1;

  if (!((1 << n) & nodeIteratorOrTreeWalkerImpl.whatToShow)) {
    return exports.FILTER_SKIP;
  }

  // Saving in a variable is important so we don't accidentally call it as a method later.
  const { filter } = nodeIteratorOrTreeWalkerImpl;

  if (filter === null) {
    return exports.FILTER_ACCEPT;
  }

  nodeIteratorOrTreeWalkerImpl._active = true;

  let result;

  // https://github.com/whatwg/dom/issues/494
  try {
    result = filter(nodeImpl);
  } finally {
    nodeIteratorOrTreeWalkerImpl._active = false;
  }

  result = conversions["unsigned short"](result);

  return result;
};

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.72.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.72.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.71.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.70.2 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.70.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.70.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.69.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.68.2 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.68.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.68.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.67.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.67.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.66.2 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.66.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.66.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.65.1 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.65.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.64.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
appmap-0.63.0 ./node_modules/jsdom/lib/jsdom/living/traversal/helpers.js