How to use the postcss-selector-parser.TAG function in postcss-selector-parser

To help you get started, we’ve selected a few postcss-selector-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github youzan / zent / packages / zent / plugins / postcss-plugin-version-attribute.js View on Github external
selector.walk(node => {
        const { type } = node;
        if (
          type === parseSelector.CLASS ||
          type === parseSelector.ID ||
          type === parseSelector.ATTRIBUTE ||
          type === parseSelector.TAG
        ) {
          interestedNode = node;
          return false; /* break */
        }
      });
      if (interestedNode) {
github sinnerschrader / schlump / src / css-matcher.js View on Github external
isTypeMatching(node) {
		switch (node.type) {
			case selectorParser.TAG:
				return this.findMatchingSibling(node, node => {
					return node.value === this.currentNode.tag;
				});
			case selectorParser.COMBINATOR:
				return this.isCombinatorMatching(node);
			case selectorParser.CLASS:
				return this.findMatchingSibling(node, node => (this.currentNode.class || '').split(' ').includes(node.value));
			case selectorParser.ATTRIBUTE:
				return this.findMatchingSibling(node, node => this.isAttributeMatching(node));
			case selectorParser.PSEUDO:
				if (node.value === ':root') {
					this.toParent();
					this.updateCurrentSiblings();
					return Object.keys(this.currentNode).length === 0;
				}
				return true;
github sinnerschrader / schlump / src / css.js View on Github external
for (let i = 0, n = selector.nodes.length; i < n; i++) {
							if (isClassSelectorNode(selector, i)) {
								let newClass = classNameCache.get(selector.nodes[i].value);
								if (!newClass) {
									newClass = selectorParser.className({value: `${ns}-${selector.nodes[i].value}`});
									classNameCache.set(selector.nodes[i].value, newClass);
								}
								selector.nodes[i].replaceWith(newClass);
								map[sourceSelector] = String(selector.last).replace(/^\./, '');
							} else if (isClassWithAttributeSelectorNode(selector, i)) {
								const classSelector = selectorParser.className({value: ns});
								selector.insertBefore(selector.nodes[i], classSelector);
								map[sourceSelector] = String(classSelector).replace(/^\./, '');
							}
						}
						if (selector.last.type === selectorParser.TAG) {
							selector.last.replaceWith(selectorParser.className({value:
								`${ns}-${selector.last.value}`}));
							map[sourceSelector] = String(selector.last).replace(/^\./, '');
						}
					}
				});
			};
github linkedin / opticss / src / Styleable.ts View on Github external
function isTag(tag: SelectorParser.Node | undefined): tag is SelectorParser.Tag {
  if (tag) {
    return tag.type === SelectorParser.TAG;
  } else {
    return false;
  }
}