source: trip-planner-front/node_modules/css-select/lib/pseudo-selectors/index.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0;
4/*
5 * Pseudo selectors
6 *
7 * Pseudo selectors are available in three forms:
8 *
9 * 1. Filters are called when the selector is compiled and return a function
10 * that has to return either false, or the results of `next()`.
11 * 2. Pseudos are called on execution. They have to return a boolean.
12 * 3. Subselects work like filters, but have an embedded selector that will be run separately.
13 *
14 * Filters are great if you want to do some pre-processing, or change the call order
15 * of `next()` and your code.
16 * Pseudos should be used to implement simple checks.
17 */
18var boolbase_1 = require("boolbase");
19var css_what_1 = require("css-what");
20var filters_1 = require("./filters");
21Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return filters_1.filters; } });
22var pseudos_1 = require("./pseudos");
23Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudos_1.pseudos; } });
24var aliases_1 = require("./aliases");
25Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return aliases_1.aliases; } });
26var subselects_1 = require("./subselects");
27function compilePseudoSelector(next, selector, options, context, compileToken) {
28 var name = selector.name, data = selector.data;
29 if (Array.isArray(data)) {
30 return subselects_1.subselects[name](next, data, options, context, compileToken);
31 }
32 if (name in aliases_1.aliases) {
33 if (data != null) {
34 throw new Error("Pseudo " + name + " doesn't have any arguments");
35 }
36 // The alias has to be parsed here, to make sure options are respected.
37 var alias = css_what_1.parse(aliases_1.aliases[name], options);
38 return subselects_1.subselects.is(next, alias, options, context, compileToken);
39 }
40 if (name in filters_1.filters) {
41 return filters_1.filters[name](next, data, options, context);
42 }
43 if (name in pseudos_1.pseudos) {
44 var pseudo_1 = pseudos_1.pseudos[name];
45 pseudos_1.verifyPseudoArgs(pseudo_1, name, data);
46 return pseudo_1 === boolbase_1.falseFunc
47 ? boolbase_1.falseFunc
48 : next === boolbase_1.trueFunc
49 ? function (elem) { return pseudo_1(elem, options, data); }
50 : function (elem) { return pseudo_1(elem, options, data) && next(elem); };
51 }
52 throw new Error("unmatched pseudo-class :" + name);
53}
54exports.compilePseudoSelector = compilePseudoSelector;
Note: See TracBrowser for help on using the repository browser.