From cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 27 Mar 2019 21:01:33 +0100 Subject: remove node_modules --- node_modules/css-select/lib/pseudos.js | 393 --------------------------------- 1 file changed, 393 deletions(-) delete mode 100644 node_modules/css-select/lib/pseudos.js (limited to 'node_modules/css-select/lib/pseudos.js') diff --git a/node_modules/css-select/lib/pseudos.js b/node_modules/css-select/lib/pseudos.js deleted file mode 100644 index f6774ecfc..000000000 --- a/node_modules/css-select/lib/pseudos.js +++ /dev/null @@ -1,393 +0,0 @@ -/* - pseudo selectors - - --- - - they are available in two forms: - * filters called when the selector - is compiled and return a function - that needs to return next() - * pseudos get called on execution - they need to return a boolean -*/ - -var DomUtils = require("domutils"), - isTag = DomUtils.isTag, - getText = DomUtils.getText, - getParent = DomUtils.getParent, - getChildren = DomUtils.getChildren, - getSiblings = DomUtils.getSiblings, - hasAttrib = DomUtils.hasAttrib, - getName = DomUtils.getName, - getAttribute= DomUtils.getAttributeValue, - getNCheck = require("nth-check"), - checkAttrib = require("./attributes.js").rules.equals, - BaseFuncs = require("boolbase"), - trueFunc = BaseFuncs.trueFunc, - falseFunc = BaseFuncs.falseFunc; - -//helper methods -function getFirstElement(elems){ - for(var i = 0; elems && i < elems.length; i++){ - if(isTag(elems[i])) return elems[i]; - } -} - -function getAttribFunc(name, value){ - var data = {name: name, value: value}; - return function attribFunc(next){ - return checkAttrib(next, data); - }; -} - -function getChildFunc(next){ - return function(elem){ - return !!getParent(elem) && next(elem); - }; -} - -var filters = { - contains: function(next, text){ - return function contains(elem){ - return next(elem) && getText(elem).indexOf(text) >= 0; - }; - }, - icontains: function(next, text){ - var itext = text.toLowerCase(); - return function icontains(elem){ - return next(elem) && - getText(elem).toLowerCase().indexOf(itext) >= 0; - }; - }, - - //location specific methods - "nth-child": function(next, rule){ - var func = getNCheck(rule); - - if(func === falseFunc) return func; - if(func === trueFunc) return getChildFunc(next); - - return function nthChild(elem){ - var siblings = getSiblings(elem); - - for(var i = 0, pos = 0; i < siblings.length; i++){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) break; - else pos++; - } - } - - return func(pos) && next(elem); - }; - }, - "nth-last-child": function(next, rule){ - var func = getNCheck(rule); - - if(func === falseFunc) return func; - if(func === trueFunc) return getChildFunc(next); - - return function nthLastChild(elem){ - var siblings = getSiblings(elem); - - for(var pos = 0, i = siblings.length - 1; i >= 0; i--){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) break; - else pos++; - } - } - - return func(pos) && next(elem); - }; - }, - "nth-of-type": function(next, rule){ - var func = getNCheck(rule); - - if(func === falseFunc) return func; - if(func === trueFunc) return getChildFunc(next); - - return function nthOfType(elem){ - var siblings = getSiblings(elem); - - for(var pos = 0, i = 0; i < siblings.length; i++){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) break; - if(getName(siblings[i]) === getName(elem)) pos++; - } - } - - return func(pos) && next(elem); - }; - }, - "nth-last-of-type": function(next, rule){ - var func = getNCheck(rule); - - if(func === falseFunc) return func; - if(func === trueFunc) return getChildFunc(next); - - return function nthLastOfType(elem){ - var siblings = getSiblings(elem); - - for(var pos = 0, i = siblings.length - 1; i >= 0; i--){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) break; - if(getName(siblings[i]) === getName(elem)) pos++; - } - } - - return func(pos) && next(elem); - }; - }, - - //TODO determine the actual root element - root: function(next){ - return function(elem){ - return !getParent(elem) && next(elem); - }; - }, - - scope: function(next, rule, options, context){ - if(!context || context.length === 0){ - //equivalent to :root - return filters.root(next); - } - - if(context.length === 1){ - //NOTE: can't be unpacked, as :has uses this for side-effects - return function(elem){ - return context[0] === elem && next(elem); - }; - } - - return function(elem){ - return context.indexOf(elem) >= 0 && next(elem); - }; - }, - - //jQuery extensions (others follow as pseudos) - checkbox: getAttribFunc("type", "checkbox"), - file: getAttribFunc("type", "file"), - password: getAttribFunc("type", "password"), - radio: getAttribFunc("type", "radio"), - reset: getAttribFunc("type", "reset"), - image: getAttribFunc("type", "image"), - submit: getAttribFunc("type", "submit") -}; - -//while filters are precompiled, pseudos get called when they are needed -var pseudos = { - empty: function(elem){ - return !getChildren(elem).some(function(elem){ - return isTag(elem) || elem.type === "text"; - }); - }, - - "first-child": function(elem){ - return getFirstElement(getSiblings(elem)) === elem; - }, - "last-child": function(elem){ - var siblings = getSiblings(elem); - - for(var i = siblings.length - 1; i >= 0; i--){ - if(siblings[i] === elem) return true; - if(isTag(siblings[i])) break; - } - - return false; - }, - "first-of-type": function(elem){ - var siblings = getSiblings(elem); - - for(var i = 0; i < siblings.length; i++){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) return true; - if(getName(siblings[i]) === getName(elem)) break; - } - } - - return false; - }, - "last-of-type": function(elem){ - var siblings = getSiblings(elem); - - for(var i = siblings.length-1; i >= 0; i--){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) return true; - if(getName(siblings[i]) === getName(elem)) break; - } - } - - return false; - }, - "only-of-type": function(elem){ - var siblings = getSiblings(elem); - - for(var i = 0, j = siblings.length; i < j; i++){ - if(isTag(siblings[i])){ - if(siblings[i] === elem) continue; - if(getName(siblings[i]) === getName(elem)) return false; - } - } - - return true; - }, - "only-child": function(elem){ - var siblings = getSiblings(elem); - - for(var i = 0; i < siblings.length; i++){ - if(isTag(siblings[i]) && siblings[i] !== elem) return false; - } - - return true; - }, - - //:matches(a, area, link)[href] - link: function(elem){ - return hasAttrib(elem, "href"); - }, - visited: falseFunc, //seems to be a valid implementation - //TODO: :any-link once the name is finalized (as an alias of :link) - - //forms - //to consider: :target - - //:matches([selected], select:not([multiple]):not(> option[selected]) > option:first-of-type) - selected: function(elem){ - if(hasAttrib(elem, "selected")) return true; - else if(getName(elem) !== "option") return false; - - //the first