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

Unified Diff: node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/lib/general.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/lib/general.js
diff --git a/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/lib/general.js b/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/lib/general.js
new file mode 100644
index 0000000000000000000000000000000000000000..3e94eb9b4f63b06c730eb959fbdd3dc3f69e2306
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/whacko/node_modules/CSSselect/lib/general.js
@@ -0,0 +1,80 @@
+var DomUtils = require("domutils"),
+ isTag = DomUtils.isTag,
+ getParent = DomUtils.getParent,
+ getChildren = DomUtils.getChildren,
+ getSiblings = DomUtils.getSiblings,
+ getName = DomUtils.getName;
+
+/*
+ all available rules
+*/
+module.exports = {
+ __proto__: null,
+
+ attribute: require("./attributes.js").compile,
+ pseudo: require("./pseudos.js").compile,
+
+ //tags
+ tag: function(next, data){
+ var name = data.name;
+ return function tag(elem){
+ return getName(elem) === name && next(elem);
+ };
+ },
+
+ //traversal
+ descendant: function(next){
+ return function descendant(elem){
+ var found = false;
+
+ while(!found && (elem = getParent(elem))){
+ found = next(elem);
+ }
+
+ return found;
+ };
+ },
+ parent: function(next){
+ return function parent(elem){
+ return getChildren(elem).some(next);
+ };
+ },
+ child: function(next){
+ return function child(elem){
+ var parent = getParent(elem);
+ return !!parent && next(parent);
+ };
+ },
+ sibling: function(next){
+ return function sibling(elem){
+ var siblings = getSiblings(elem);
+
+ for(var i = 0; i < siblings.length; i++){
+ if(isTag(siblings[i])){
+ if(siblings[i] === elem) break;
+ if(next(siblings[i])) return true;
+ }
+ }
+
+ return false;
+ };
+ },
+ adjacent: function(next){
+ return function adjacent(elem){
+ var siblings = getSiblings(elem),
+ lastElement;
+
+ for(var i = 0; i < siblings.length; i++){
+ if(isTag(siblings[i])){
+ if(siblings[i] === elem) break;
+ lastElement = siblings[i];
+ }
+ }
+
+ return !!lastElement && next(lastElement);
+ };
+ },
+ universal: function(next){
+ return next;
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698