use NestingSelector everywhere, include in SimpleSelector

pull/9549/head
Rich Harris 3 years ago
parent 633e05a5a6
commit 4d4d973622

@ -162,7 +162,7 @@ function read_selector_list(parser, inside_pseudo_class = false) {
function read_selector(parser, inside_pseudo_class = false) {
const list_start = parser.index;
/** @type {Array<import('#compiler').Css.SimpleSelector | import('#compiler').Css.Combinator | import('#compiler').Css.NestingSelector>} */
/** @type {Array<import('#compiler').Css.SimpleSelector | import('#compiler').Css.Combinator>} */
const children = [];
while (parser.index < parser.template.length) {
@ -170,7 +170,7 @@ function read_selector(parser, inside_pseudo_class = false) {
if (parser.eat('&')) {
children.push({
type: 'NestedSelector',
type: 'NestingSelector',
name: '&',
start,
end: parser.index

@ -872,7 +872,7 @@ function group_selectors(selector, parent_selector) {
if (parent_selector) {
const nested_rule_indices = selector.children
.map((child, index) => (child.type === 'NestedSelector' ? index : -1))
.map((child, index) => (child.type === 'NestingSelector' ? index : -1))
.filter((index) => index !== -1);
const parent_children = parent_selector.node.children.map((child) => ({
@ -900,7 +900,7 @@ function group_selectors(selector, parent_selector) {
if (child.type === 'Combinator') {
block = new Block(child);
blocks.push(block);
} else if (child.type === 'NestedSelector') {
} else if (child.type === 'NestingSelector') {
// Don't think we need to add it here
} else {
block.add(child);

@ -25,7 +25,7 @@ export interface SelectorList extends BaseNode {
export interface Selector extends BaseNode {
type: 'Selector';
children: Array<SimpleSelector | Combinator | NestingSelector>;
children: Array<SimpleSelector | Combinator>;
}
export interface TypeSelector extends BaseNode {
@ -72,6 +72,11 @@ export interface Nth extends BaseNode {
value: string;
}
export interface NestingSelector extends BaseNode {
type: 'NestingSelector';
name: '&';
}
export type SimpleSelector =
| TypeSelector
| IdSelector
@ -80,18 +85,14 @@ export type SimpleSelector =
| PseudoElementSelector
| PseudoClassSelector
| Percentage
| Nth;
| Nth
| NestingSelector;
export interface Combinator extends BaseNode {
type: 'Combinator';
name: string;
}
export interface NestingSelector extends BaseNode {
type: 'NestedSelector';
name: '&';
}
export interface Block extends BaseNode {
type: 'Block';
children: Array<Declaration | Rule | Atrule>;

Loading…
Cancel
Save