pull/10482/head
Rich Harris 3 years ago
parent 0d0cc80cec
commit ab60b6a045

@ -102,14 +102,7 @@ export function convert(source, ast) {
},
instance,
module,
css: ast.css
? walk(ast.css, null, {
_(node) {
// @ts-ignore
delete node.parent;
}
})
: undefined
css: ast.css ? visit(ast.css) : undefined
};
},
AnimateDirective(node) {
@ -192,6 +185,24 @@ export function convert(source, ast) {
ClassDirective(node) {
return { ...node, type: 'Class' };
},
ComplexSelector(node, { visit }) {
const children = [];
for (const child of node.children) {
if (child.combinator) {
children.push(child.combinator);
}
children.push(...child.selectors);
}
return {
type: 'Selector',
start: node.start,
end: node.end,
children
};
},
Component(node, { visit }) {
return {
type: 'InlineComponent',

@ -1,4 +1,4 @@
import type { StyleDirective as LegacyStyleDirective, Text } from '#compiler';
import type { StyleDirective as LegacyStyleDirective, Text, Css } from '#compiler';
import type {
ArrayExpression,
AssignmentExpression,
@ -227,9 +227,17 @@ export type LegacyElementLike =
| LegacyTitle
| LegacyWindow;
export interface LegacySelector extends BaseNode {
type: 'Selector';
children: Array<Css.Combinator | Css.SimpleSelector>;
}
export type LegacyCssNode = LegacySelector;
export type LegacySvelteNode =
| LegacyConstTag
| LegacyElementLike
| LegacyAttributeLike
| LegacyAttributeShorthand
| LegacyCssNode
| Text;

@ -13,15 +13,23 @@
"end": 86,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 60,
"end": 86,
"children": [
{
"type": "PseudoElementSelector",
"name": "view-transition-old",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoElementSelector",
"name": "view-transition-old",
"start": 60,
"end": 81
}
],
"start": 60,
"end": 81
"end": 86
}
]
}
@ -52,33 +60,49 @@
"end": 146,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 111,
"end": 146,
"children": [
{
"type": "PseudoClassSelector",
"name": "global",
"args": {
"type": "SelectorList",
"start": 119,
"end": 145,
"children": [
{
"type": "Selector",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoClassSelector",
"name": "global",
"args": {
"type": "SelectorList",
"start": 119,
"end": 145,
"children": [
{
"type": "PseudoElementSelector",
"name": "view-transition-old",
"type": "ComplexSelector",
"start": 119,
"end": 140
"end": 145,
"children": [
{
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoElementSelector",
"name": "view-transition-old",
"start": 119,
"end": 140
}
],
"start": 119,
"end": 145
}
]
}
]
}
]
},
},
"start": 111,
"end": 146
}
],
"start": 111,
"end": 146
}
@ -111,15 +135,23 @@
"end": 199,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 171,
"end": 199,
"children": [
{
"type": "PseudoElementSelector",
"name": "highlight",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoElementSelector",
"name": "highlight",
"start": 171,
"end": 182
}
],
"start": 171,
"end": 182
"end": 199
}
]
}
@ -150,21 +182,29 @@
"end": 245,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 220,
"end": 245,
"children": [
{
"type": "TypeSelector",
"name": "custom-element",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "TypeSelector",
"name": "custom-element",
"start": 220,
"end": 234
},
{
"type": "PseudoElementSelector",
"name": "part",
"start": 234,
"end": 240
}
],
"start": 220,
"end": 234
},
{
"type": "PseudoElementSelector",
"name": "part",
"start": 234,
"end": 240
"end": 245
}
]
}
@ -195,15 +235,23 @@
"end": 285,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 266,
"end": 285,
"children": [
{
"type": "PseudoElementSelector",
"name": "slotted",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoElementSelector",
"name": "slotted",
"start": 266,
"end": 275
}
],
"start": 266,
"end": 275
"end": 285
}
]
}
@ -234,58 +282,89 @@
"end": 359,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 306,
"end": 359,
"children": [
{
"type": "PseudoClassSelector",
"name": "is",
"args": {
"type": "SelectorList",
"start": 324,
"end": 355,
"children": [
{
"type": "Selector",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "PseudoClassSelector",
"name": "is",
"args": {
"type": "SelectorList",
"start": 324,
"end": 330,
"children": [
{
"type": "TypeSelector",
"name": "button",
"start": 324,
"end": 330
}
]
},
{
"type": "Selector",
"start": 349,
"end": 355,
"children": [
{
"type": "TypeSelector",
"name": "h1",
"start": 349,
"end": 351
},
{
"type": "Combinator",
"name": "+",
"start": 352,
"end": 353
"type": "ComplexSelector",
"start": 324,
"end": 330,
"children": [
{
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "TypeSelector",
"name": "button",
"start": 324,
"end": 330
}
],
"start": 324,
"end": 330
}
]
},
{
"type": "TypeSelector",
"name": "p",
"start": 354,
"end": 355
"type": "ComplexSelector",
"start": 349,
"end": 355,
"children": [
{
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "TypeSelector",
"name": "h1",
"start": 349,
"end": 351
}
],
"start": 349,
"end": 351
},
{
"type": "RelativeSelector",
"combinator": {
"type": "Combinator",
"name": "+",
"start": 352,
"end": 353
},
"selectors": [
{
"type": "TypeSelector",
"name": "p",
"start": 354,
"end": 355
}
],
"start": 351,
"end": 355
}
]
}
]
}
]
},
},
"start": 306,
"end": 359
}
],
"start": 306,
"end": 359
}

@ -21,13 +21,21 @@
"end": 139,
"children": [
{
"type": "Selector",
"type": "ComplexSelector",
"start": 137,
"end": 139,
"children": [
{
"type": "TypeSelector",
"name": "h1",
"type": "RelativeSelector",
"combinator": null,
"selectors": [
{
"type": "TypeSelector",
"name": "h1",
"start": 137,
"end": 139
}
],
"start": 137,
"end": 139
}

Loading…
Cancel
Save