Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1229)

Unified Diff: node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/node_modules/domutils/lib/helpers.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/node_modules/domutils/lib/helpers.js
diff --git a/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/node_modules/domutils/lib/helpers.js b/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/node_modules/domutils/lib/helpers.js
new file mode 100644
index 0000000000000000000000000000000000000000..476b8eb51b67247c802ad3a77d18ab4266bbb3b7
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/node_modules/domutils/lib/helpers.js
@@ -0,0 +1,31 @@
+// removeSubsets
+// Given an array of nodes, remove any member that is contained by another.
+exports.removeSubsets = function(nodes) {
+ var idx = nodes.length, node, ancestor, replace;
+
+ // Check if each node (or one of its ancestors) is already contained in the
+ // array.
+ while (--idx > -1) {
+ node = ancestor = nodes[idx];
+
+ // Temporarily remove the node under consideration
+ nodes[idx] = null;
+ replace = true;
+
+ while (ancestor) {
+ if (nodes.indexOf(ancestor) > -1) {
+ replace = false;
+ nodes.splice(idx, 1);
+ break;
+ }
+ ancestor = ancestor.parent;
+ }
+
+ // If the node has been found to be unique, re-insert it.
+ if (replace) {
+ nodes[idx] = node;
+ }
+ }
+
+ return nodes;
+};

Powered by Google App Engine
This is Rietveld 408576698