in src/services/selectorPrinting.ts [417:463]
public processSelector(selector: nodes.Selector): void {
let parentElement: Element | null = null;
if (!(this.element instanceof RootElement)) {
if (selector.getChildren().some((c) => c.hasChildren() && c.getChild(0)!.type === nodes.NodeType.SelectorCombinator)) {
const curr = this.element.findRoot();
if (curr.parent instanceof RootElement) {
parentElement = this.element;
this.element = curr.parent;
this.element.removeChild(curr);
this.prev = null;
}
}
}
for (const selectorChild of selector.getChildren()) {
if (selectorChild instanceof nodes.SimpleSelector) {
if (this.prev instanceof nodes.SimpleSelector) {
const labelElement = new LabelElement('\u2026');
this.element.addChild(labelElement);
this.element = labelElement;
} else if (this.prev && (this.prev.matches('+') || this.prev.matches('~')) && this.element.parent) {
this.element = <Element>this.element.parent;
}
if (this.prev && this.prev.matches('~')) {
this.element.addChild(new LabelElement('\u22EE'));
}
const thisElement = toElement(<nodes.SimpleSelector>selectorChild, parentElement);
const root = thisElement.findRoot();
this.element.addChild(root);
this.element = thisElement;
}
if (selectorChild instanceof nodes.SimpleSelector ||
selectorChild.type === nodes.NodeType.SelectorCombinatorParent ||
selectorChild.type === nodes.NodeType.SelectorCombinatorShadowPiercingDescendant ||
selectorChild.type === nodes.NodeType.SelectorCombinatorSibling ||
selectorChild.type === nodes.NodeType.SelectorCombinatorAllSiblings) {
this.prev = selectorChild;
}
}
}