1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.isNode = isNode;
|
---|
5 | exports.isPseudoElement = isPseudoElement;
|
---|
6 | exports.isPseudoClass = isPseudoClass;
|
---|
7 | exports.isContainer = isContainer;
|
---|
8 | exports.isNamespace = isNamespace;
|
---|
9 | exports.isUniversal = exports.isTag = exports.isString = exports.isSelector = exports.isRoot = exports.isPseudo = exports.isNesting = exports.isIdentifier = exports.isComment = exports.isCombinator = exports.isClassName = exports.isAttribute = void 0;
|
---|
10 |
|
---|
11 | var _types = require("./types");
|
---|
12 |
|
---|
13 | var _IS_TYPE;
|
---|
14 |
|
---|
15 | var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
|
---|
16 |
|
---|
17 | function isNode(node) {
|
---|
18 | return typeof node === "object" && IS_TYPE[node.type];
|
---|
19 | }
|
---|
20 |
|
---|
21 | function isNodeType(type, node) {
|
---|
22 | return isNode(node) && node.type === type;
|
---|
23 | }
|
---|
24 |
|
---|
25 | var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
|
---|
26 | exports.isAttribute = isAttribute;
|
---|
27 | var isClassName = isNodeType.bind(null, _types.CLASS);
|
---|
28 | exports.isClassName = isClassName;
|
---|
29 | var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
|
---|
30 | exports.isCombinator = isCombinator;
|
---|
31 | var isComment = isNodeType.bind(null, _types.COMMENT);
|
---|
32 | exports.isComment = isComment;
|
---|
33 | var isIdentifier = isNodeType.bind(null, _types.ID);
|
---|
34 | exports.isIdentifier = isIdentifier;
|
---|
35 | var isNesting = isNodeType.bind(null, _types.NESTING);
|
---|
36 | exports.isNesting = isNesting;
|
---|
37 | var isPseudo = isNodeType.bind(null, _types.PSEUDO);
|
---|
38 | exports.isPseudo = isPseudo;
|
---|
39 | var isRoot = isNodeType.bind(null, _types.ROOT);
|
---|
40 | exports.isRoot = isRoot;
|
---|
41 | var isSelector = isNodeType.bind(null, _types.SELECTOR);
|
---|
42 | exports.isSelector = isSelector;
|
---|
43 | var isString = isNodeType.bind(null, _types.STRING);
|
---|
44 | exports.isString = isString;
|
---|
45 | var isTag = isNodeType.bind(null, _types.TAG);
|
---|
46 | exports.isTag = isTag;
|
---|
47 | var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
|
---|
48 | exports.isUniversal = isUniversal;
|
---|
49 |
|
---|
50 | function isPseudoElement(node) {
|
---|
51 | return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after");
|
---|
52 | }
|
---|
53 |
|
---|
54 | function isPseudoClass(node) {
|
---|
55 | return isPseudo(node) && !isPseudoElement(node);
|
---|
56 | }
|
---|
57 |
|
---|
58 | function isContainer(node) {
|
---|
59 | return !!(isNode(node) && node.walk);
|
---|
60 | }
|
---|
61 |
|
---|
62 | function isNamespace(node) {
|
---|
63 | return isAttribute(node) || isTag(node);
|
---|
64 | } |
---|