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/LICENSE | 11 - node_modules/css-select/README.md | 133 ------- node_modules/css-select/index.js | 59 ---- node_modules/css-select/lib/attributes.js | 181 ---------- node_modules/css-select/lib/compile.js | 192 ---------- node_modules/css-select/lib/general.js | 89 ----- node_modules/css-select/lib/procedure.json | 11 - node_modules/css-select/lib/pseudos.js | 393 --------------------- node_modules/css-select/lib/sort.js | 80 ----- .../css-select/node_modules/domutils/.npmignore | 1 - .../css-select/node_modules/domutils/LICENSE | 11 - .../css-select/node_modules/domutils/index.js | 14 - .../node_modules/domutils/lib/helpers.js | 141 -------- .../css-select/node_modules/domutils/lib/legacy.js | 87 ----- .../node_modules/domutils/lib/manipulation.js | 77 ---- .../node_modules/domutils/lib/querying.js | 94 ----- .../node_modules/domutils/lib/stringify.js | 22 -- .../node_modules/domutils/lib/traversal.js | 24 -- .../css-select/node_modules/domutils/package.json | 46 --- .../css-select/node_modules/domutils/readme.md | 1 - .../node_modules/domutils/test/fixture.js | 6 - .../node_modules/domutils/test/tests/helpers.js | 89 ----- .../node_modules/domutils/test/tests/legacy.js | 119 ------- .../node_modules/domutils/test/tests/traversal.js | 17 - .../css-select/node_modules/domutils/test/utils.js | 9 - node_modules/css-select/package.json | 61 ---- 26 files changed, 1968 deletions(-) delete mode 100644 node_modules/css-select/LICENSE delete mode 100644 node_modules/css-select/README.md delete mode 100644 node_modules/css-select/index.js delete mode 100644 node_modules/css-select/lib/attributes.js delete mode 100644 node_modules/css-select/lib/compile.js delete mode 100644 node_modules/css-select/lib/general.js delete mode 100644 node_modules/css-select/lib/procedure.json delete mode 100644 node_modules/css-select/lib/pseudos.js delete mode 100644 node_modules/css-select/lib/sort.js delete mode 100644 node_modules/css-select/node_modules/domutils/.npmignore delete mode 100644 node_modules/css-select/node_modules/domutils/LICENSE delete mode 100644 node_modules/css-select/node_modules/domutils/index.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/helpers.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/legacy.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/manipulation.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/querying.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/stringify.js delete mode 100644 node_modules/css-select/node_modules/domutils/lib/traversal.js delete mode 100644 node_modules/css-select/node_modules/domutils/package.json delete mode 100644 node_modules/css-select/node_modules/domutils/readme.md delete mode 100644 node_modules/css-select/node_modules/domutils/test/fixture.js delete mode 100644 node_modules/css-select/node_modules/domutils/test/tests/helpers.js delete mode 100644 node_modules/css-select/node_modules/domutils/test/tests/legacy.js delete mode 100644 node_modules/css-select/node_modules/domutils/test/tests/traversal.js delete mode 100644 node_modules/css-select/node_modules/domutils/test/utils.js delete mode 100644 node_modules/css-select/package.json (limited to 'node_modules/css-select') diff --git a/node_modules/css-select/LICENSE b/node_modules/css-select/LICENSE deleted file mode 100644 index c464f863e..000000000 --- a/node_modules/css-select/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) Felix Böhm -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/css-select/README.md b/node_modules/css-select/README.md deleted file mode 100644 index e36282fe2..000000000 --- a/node_modules/css-select/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# css-select [![NPM version](http://img.shields.io/npm/v/css-select.svg)](https://npmjs.org/package/css-select) [![Build Status](https://travis-ci.org/fb55/css-select.svg?branch=master)](http://travis-ci.org/fb55/css-select) [![Downloads](https://img.shields.io/npm/dm/css-select.svg)](https://npmjs.org/package/css-select) [![Coverage](https://coveralls.io/repos/fb55/css-select/badge.svg?branch=master)](https://coveralls.io/r/fb55/css-select) - -a CSS selector compiler/engine - -## What? - -css-select turns CSS selectors into functions that tests if elements match them. When searching for elements, testing is executed "from the top", similar to how browsers execute CSS selectors. - -In its default configuration, css-select queries the DOM structure of the [`domhandler`](https://github.com/fb55/domhandler) module (also known as htmlparser2 DOM). - -__Features:__ - -- Full implementation of CSS3 selectors -- Partial implementation of jQuery/Sizzle extensions -- Very high test coverage -- Pretty good performance - -## Why? - -The traditional approach of executing CSS selectors, named left-to-right execution, is to execute every component of the selector in order, from left to right _(duh)_. The execution of the selector `a b` for example will first query for `a` elements, then search these for `b` elements. (That's the approach of eg. [`Sizzle`](https://github.com/jquery/sizzle), [`nwmatcher`](https://github.com/dperini/nwmatcher/) and [`qwery`](https://github.com/ded/qwery).) - -While this works, it has some downsides: Children of `a`s will be checked multiple times; first, to check if they are also `a`s, then, for every superior `a` once, if they are `b`s. Using [Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be `O(n^(k+1))`, where `k` is the number of descendant selectors (that's the space in the example above). - -The far more efficient approach is to first look for `b` elements, then check if they have superior `a` elements: Using big O notation again, that would be `O(n)`. That's called right-to-left execution. - -And that's what css-select does – and why it's quite performant. - -## How does it work? - -By building a stack of functions. - -_Wait, what?_ - -Okay, so let's suppose we want to compile the selector `a b` again, for right-to-left execution. We start by _parsing_ the selector, which means we turn the selector into an array of the building-blocks of the selector, so we can distinguish them easily. That's what the [`css-what`](https://github.com/fb55/css-what) module is for, if you want to have a look. - -Anyway, after parsing, we end up with an array like this one: - -```js -[ - { type: 'tag', name: 'a' }, - { type: 'descendant' }, - { type: 'tag', name: 'b' } -] -``` - -Actually, this array is wrapped in another array, but that's another story (involving commas in selectors). - -Now that we know the meaning of every part of the selector, we can compile it. That's where it becomes interesting. - -The basic idea is to turn every part of the selector into a function, which takes an element as its only argument. The function checks whether a passed element matches its part of the selector: If it does, the element is passed to the next turned-into-a-function part of the selector, which does the same. If an element is accepted by all parts of the selector, it _matches_ the selector and double rainbow ALL THE WAY. - -As said before, we want to do right-to-left execution with all the big O improvements nonsense, so elements are passed from the rightmost part of the selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course `a`). - -_//TODO: More in-depth description. Implementation details. Build a spaceship._ - -## API - -```js -var CSSselect = require("css-select"); -``` - -#### `CSSselect(query, elems, options)` - -Queries `elems`, returns an array containing all matches. - -- `query` can be either a CSS selector or a function. -- `elems` can be either an array of elements, or a single element. If it is an element, its children will be queried. -- `options` is described below. - -Aliases: `CSSselect.selectAll(query, elems)`, `CSSselect.iterate(query, elems)`. - -#### `CSSselect.compile(query)` - -Compiles the query, returns a function. - -#### `CSSselect.is(elem, query, options)` - -Tests whether or not an element is matched by `query`. `query` can be either a CSS selector or a function. - -#### `CSSselect.selectOne(query, elems, options)` - -Arguments are the same as for `CSSselect(query, elems)`. Only returns the first match, or `null` if there was no match. - -### Options - -- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`. -- `strict`: Limits the module to only use CSS3 selectors. Default: `false`. -- `rootFunc`: The last function in the stack, will be called with the last element that's looked at. Should return `true`. - -## Supported selectors - -_As defined by CSS 4 and / or jQuery._ - -* Universal (`*`) -* Tag (``) -* Descendant (` `) -* Child (`>`) -* Parent (`<`) * -* Sibling (`+`) -* Adjacent (`~`) -* Attribute (`[attr=foo]`), with supported comparisons: - * `[attr]` (existential) - * `=` - * `~=` - * `|=` - * `*=` - * `^=` - * `$=` - * `!=` * - * Also, `i` can be added after the comparison to make the comparison case-insensitive (eg. `[attr=foo i]`) * -* Pseudos: - * `:not` - * `:contains` * - * `:icontains` * (case-insensitive version of `:contains`) - * `:has` * - * `:root` - * `:empty` - * `:parent` * - * `:[first|last]-child[-of-type]` - * `:only-of-type`, `:only-child` - * `:nth-[last-]child[-of-type]` - * `:link`, `:visited` (the latter doesn't match any elements) - * `:selected` *, `:checked` - * `:enabled`, `:disabled` - * `:required`, `:optional` - * `:header`, `:button`, `:input`, `:text`, `:checkbox`, `:file`, `:password`, `:reset`, `:radio` etc. * - * `:matches` * - -__*__: Not part of CSS3 - ---- - -License: BSD-like diff --git a/node_modules/css-select/index.js b/node_modules/css-select/index.js deleted file mode 100644 index 4179d196b..000000000 --- a/node_modules/css-select/index.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -module.exports = CSSselect; - -var Pseudos = require("./lib/pseudos.js"), - DomUtils = require("domutils"), - findOne = DomUtils.findOne, - findAll = DomUtils.findAll, - getChildren = DomUtils.getChildren, - removeSubsets = DomUtils.removeSubsets, - falseFunc = require("boolbase").falseFunc, - compile = require("./lib/compile.js"), - compileUnsafe = compile.compileUnsafe, - compileToken = compile.compileToken; - -function getSelectorFunc(searchFunc){ - return function select(query, elems, options){ - if(typeof query !== "function") query = compileUnsafe(query, options, elems); - if(!Array.isArray(elems)) elems = getChildren(elems); - else elems = removeSubsets(elems); - return searchFunc(query, elems); - }; -} - -var selectAll = getSelectorFunc(function selectAll(query, elems){ - return (query === falseFunc || !elems || elems.length === 0) ? [] : findAll(query, elems); -}); - -var selectOne = getSelectorFunc(function selectOne(query, elems){ - return (query === falseFunc || !elems || elems.length === 0) ? null : findOne(query, elems); -}); - -function is(elem, query, options){ - return (typeof query === "function" ? query : compile(query, options))(elem); -} - -/* - the exported interface -*/ -function CSSselect(query, elems, options){ - return selectAll(query, elems, options); -} - -CSSselect.compile = compile; -CSSselect.filters = Pseudos.filters; -CSSselect.pseudos = Pseudos.pseudos; - -CSSselect.selectAll = selectAll; -CSSselect.selectOne = selectOne; - -CSSselect.is = is; - -//legacy methods (might be removed) -CSSselect.parse = compile; -CSSselect.iterate = selectAll; - -//hooks -CSSselect._compileUnsafe = compileUnsafe; -CSSselect._compileToken = compileToken; diff --git a/node_modules/css-select/lib/attributes.js b/node_modules/css-select/lib/attributes.js deleted file mode 100644 index a8689c01c..000000000 --- a/node_modules/css-select/lib/attributes.js +++ /dev/null @@ -1,181 +0,0 @@ -var DomUtils = require("domutils"), - hasAttrib = DomUtils.hasAttrib, - getAttributeValue = DomUtils.getAttributeValue, - falseFunc = require("boolbase").falseFunc; - -//https://github.com/slevithan/XRegExp/blob/master/src/xregexp.js#L469 -var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g; - -/* - attribute selectors -*/ - -var attributeRules = { - __proto__: null, - equals: function(next, data){ - var name = data.name, - value = data.value; - - if(data.ignoreCase){ - value = value.toLowerCase(); - - return function equalsIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.toLowerCase() === value && next(elem); - }; - } - - return function equals(elem){ - return getAttributeValue(elem, name) === value && next(elem); - }; - }, - hyphen: function(next, data){ - var name = data.name, - value = data.value, - len = value.length; - - if(data.ignoreCase){ - value = value.toLowerCase(); - - return function hyphenIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && - (attr.length === len || attr.charAt(len) === "-") && - attr.substr(0, len).toLowerCase() === value && - next(elem); - }; - } - - return function hyphen(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && - attr.substr(0, len) === value && - (attr.length === len || attr.charAt(len) === "-") && - next(elem); - }; - }, - element: function(next, data){ - var name = data.name, - value = data.value; - - if(/\s/.test(value)){ - return falseFunc; - } - - value = value.replace(reChars, "\\$&"); - - var pattern = "(?:^|\\s)" + value + "(?:$|\\s)", - flags = data.ignoreCase ? "i" : "", - regex = new RegExp(pattern, flags); - - return function element(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && regex.test(attr) && next(elem); - }; - }, - exists: function(next, data){ - var name = data.name; - return function exists(elem){ - return hasAttrib(elem, name) && next(elem); - }; - }, - start: function(next, data){ - var name = data.name, - value = data.value, - len = value.length; - - if(len === 0){ - return falseFunc; - } - - if(data.ignoreCase){ - value = value.toLowerCase(); - - return function startIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.substr(0, len).toLowerCase() === value && next(elem); - }; - } - - return function start(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.substr(0, len) === value && next(elem); - }; - }, - end: function(next, data){ - var name = data.name, - value = data.value, - len = -value.length; - - if(len === 0){ - return falseFunc; - } - - if(data.ignoreCase){ - value = value.toLowerCase(); - - return function endIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.substr(len).toLowerCase() === value && next(elem); - }; - } - - return function end(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.substr(len) === value && next(elem); - }; - }, - any: function(next, data){ - var name = data.name, - value = data.value; - - if(value === ""){ - return falseFunc; - } - - if(data.ignoreCase){ - var regex = new RegExp(value.replace(reChars, "\\$&"), "i"); - - return function anyIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && regex.test(attr) && next(elem); - }; - } - - return function any(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.indexOf(value) >= 0 && next(elem); - }; - }, - not: function(next, data){ - var name = data.name, - value = data.value; - - if(value === ""){ - return function notEmpty(elem){ - return !!getAttributeValue(elem, name) && next(elem); - }; - } else if(data.ignoreCase){ - value = value.toLowerCase(); - - return function notIC(elem){ - var attr = getAttributeValue(elem, name); - return attr != null && attr.toLowerCase() !== value && next(elem); - }; - } - - return function not(elem){ - return getAttributeValue(elem, name) !== value && next(elem); - }; - } -}; - -module.exports = { - compile: function(next, data, options){ - if(options && options.strict && ( - data.ignoreCase || data.action === "not" - )) throw SyntaxError("Unsupported attribute selector"); - return attributeRules[data.action](next, data); - }, - rules: attributeRules -}; diff --git a/node_modules/css-select/lib/compile.js b/node_modules/css-select/lib/compile.js deleted file mode 100644 index 91ac5925e..000000000 --- a/node_modules/css-select/lib/compile.js +++ /dev/null @@ -1,192 +0,0 @@ -/* - compiles a selector to an executable function -*/ - -module.exports = compile; -module.exports.compileUnsafe = compileUnsafe; -module.exports.compileToken = compileToken; - -var parse = require("css-what"), - DomUtils = require("domutils"), - isTag = DomUtils.isTag, - Rules = require("./general.js"), - sortRules = require("./sort.js"), - BaseFuncs = require("boolbase"), - trueFunc = BaseFuncs.trueFunc, - falseFunc = BaseFuncs.falseFunc, - procedure = require("./procedure.json"); - -function compile(selector, options, context){ - var next = compileUnsafe(selector, options, context); - return wrap(next); -} - -function wrap(next){ - return function base(elem){ - return isTag(elem) && next(elem); - }; -} - -function compileUnsafe(selector, options, context){ - var token = parse(selector, options); - return compileToken(token, options, context); -} - -function includesScopePseudo(t){ - return t.type === "pseudo" && ( - t.name === "scope" || ( - Array.isArray(t.data) && - t.data.some(function(data){ - return data.some(includesScopePseudo); - }) - ) - ); -} - -var DESCENDANT_TOKEN = {type: "descendant"}, - SCOPE_TOKEN = {type: "pseudo", name: "scope"}, - PLACEHOLDER_ELEMENT = {}, - getParent = DomUtils.getParent; - -//CSS 4 Spec (Draft): 3.3.1. Absolutizing a Scope-relative Selector -//http://www.w3.org/TR/selectors4/#absolutizing -function absolutize(token, context){ - //TODO better check if context is document - var hasContext = !!context && !!context.length && context.every(function(e){ - return e === PLACEHOLDER_ELEMENT || !!getParent(e); - }); - - - token.forEach(function(t){ - if(t.length > 0 && isTraversal(t[0]) && t[0].type !== "descendant"){ - //don't return in else branch - } else if(hasContext && !includesScopePseudo(t)){ - t.unshift(DESCENDANT_TOKEN); - } else { - return; - } - - t.unshift(SCOPE_TOKEN); - }); -} - -function compileToken(token, options, context){ - token = token.filter(function(t){ return t.length > 0; }); - - token.forEach(sortRules); - - var isArrayContext = Array.isArray(context); - - context = (options && options.context) || context; - - if(context && !isArrayContext) context = [context]; - - absolutize(token, context); - - return token - .map(function(rules){ return compileRules(rules, options, context, isArrayContext); }) - .reduce(reduceRules, falseFunc); -} - -function isTraversal(t){ - return procedure[t.type] < 0; -} - -function compileRules(rules, options, context, isArrayContext){ - var acceptSelf = (isArrayContext && rules[0].name === "scope" && rules[1].type === "descendant"); - return rules.reduce(function(func, rule, index){ - if(func === falseFunc) return func; - return Rules[rule.type](func, rule, options, context, acceptSelf && index === 1); - }, options && options.rootFunc || trueFunc); -} - -function reduceRules(a, b){ - if(b === falseFunc || a === trueFunc){ - return a; - } - if(a === falseFunc || b === trueFunc){ - return b; - } - - return function combine(elem){ - return a(elem) || b(elem); - }; -} - -//:not, :has and :matches have to compile selectors -//doing this in lib/pseudos.js would lead to circular dependencies, -//so we add them here - -var Pseudos = require("./pseudos.js"), - filters = Pseudos.filters, - existsOne = DomUtils.existsOne, - isTag = DomUtils.isTag, - getChildren = DomUtils.getChildren; - - -function containsTraversal(t){ - return t.some(isTraversal); -} - -filters.not = function(next, token, options, context){ - var opts = { - xmlMode: !!(options && options.xmlMode), - strict: !!(options && options.strict) - }; - - if(opts.strict){ - if(token.length > 1 || token.some(containsTraversal)){ - throw new SyntaxError("complex selectors in :not aren't allowed in strict mode"); - } - } - - var func = compileToken(token, opts, context); - - if(func === falseFunc) return next; - if(func === trueFunc) return falseFunc; - - return function(elem){ - return !func(elem) && next(elem); - }; -}; - -filters.has = function(next, token, options){ - var opts = { - xmlMode: !!(options && options.xmlMode), - strict: !!(options && options.strict) - }; - - //FIXME: Uses an array as a pointer to the current element (side effects) - var context = token.some(containsTraversal) ? [PLACEHOLDER_ELEMENT] : null; - - var func = compileToken(token, opts, context); - - if(func === falseFunc) return falseFunc; - if(func === trueFunc) return function(elem){ - return getChildren(elem).some(isTag) && next(elem); - }; - - func = wrap(func); - - if(context){ - return function has(elem){ - return next(elem) && ( - (context[0] = elem), existsOne(func, getChildren(elem)) - ); - }; - } - - return function has(elem){ - return next(elem) && existsOne(func, getChildren(elem)); - }; -}; - -filters.matches = function(next, token, options, context){ - var opts = { - xmlMode: !!(options && options.xmlMode), - strict: !!(options && options.strict), - rootFunc: next - }; - - return compileToken(token, opts, context); -}; diff --git a/node_modules/css-select/lib/general.js b/node_modules/css-select/lib/general.js deleted file mode 100644 index fbc960fe9..000000000 --- a/node_modules/css-select/lib/general.js +++ /dev/null @@ -1,89 +0,0 @@ -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, rule, options, context, acceptSelf){ - return function descendant(elem){ - - if (acceptSelf && next(elem)) return true; - - var found = false; - - while(!found && (elem = getParent(elem))){ - found = next(elem); - } - - return found; - }; - }, - parent: function(next, data, options){ - if(options && options.strict) throw SyntaxError("Parent selector isn't part of CSS3"); - - return function parent(elem){ - return getChildren(elem).some(test); - }; - - function test(elem){ - return isTag(elem) && next(elem); - } - }, - 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; - } -}; \ No newline at end of file diff --git a/node_modules/css-select/lib/procedure.json b/node_modules/css-select/lib/procedure.json deleted file mode 100644 index e836de117..000000000 --- a/node_modules/css-select/lib/procedure.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "universal": 50, - "tag": 30, - "attribute": 1, - "pseudo": 0, - "descendant": -1, - "child": -1, - "parent": -1, - "sibling": -1, - "adjacent": -1 -} 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