Sha256: f56991d722367dfd55f2a61f152a615a94c0c3f76fd94a23b2c4e9b9eec5aa7e

Contents?: true

Size: 1.15 KB

Versions: 26

Compression:

Stored size: 1.15 KB

Contents

"use strict";
const DOMException = require("../generated/DOMException");
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

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/traversal/helpers.js