Skip to content

Commit 0d5e05a

Browse files
committed
fix: improve pseudo elements parsing
1 parent 98a72f5 commit 0d5e05a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/svelte/src/compiler/phases/1-parse/read/style.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,22 @@ function read_selector(parser, inside_pseudo_class = false) {
219219
start,
220220
end: parser.index
221221
});
222-
} else if (parser.eat('::')) {
223-
children.push({
224-
type: 'PseudoElementSelector',
225-
name: read_identifier(parser),
226-
start,
227-
end: parser.index
228-
});
229222
} else if (parser.eat(':')) {
223+
const psuedo_element = parser.eat(':');
224+
230225
const name = read_identifier(parser);
231226

232-
/** @type {null | import('#compiler').Css.SelectorList} */
233227
let args = null;
234228

235229
if (parser.eat('(')) {
236230
args = read_selector_list(parser, true);
237231
parser.eat(')', true);
238-
} else if (name === 'global') {
232+
} else if (!psuedo_element && name === 'global') {
239233
error(parser.index, 'invalid-css-global-selector');
240234
}
241235

242236
children.push({
243-
type: 'PseudoClassSelector',
237+
type: psuedo_element ? 'PseudoElementSelector' : 'PseudoClassSelector',
244238
name,
245239
args,
246240
start,

packages/svelte/src/compiler/types/css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface AttributeSelector extends BaseNode {
5454
export interface PseudoElementSelector extends BaseNode {
5555
type: 'PseudoElementSelector';
5656
name: string;
57+
args: SelectorList | null;
5758
}
5859

5960
export interface PseudoClassSelector extends BaseNode {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<style>
2+
:root::view-transition-old(*) {
3+
animation: 90ms cubic-bezier(0.4, 0, 1, 1) both fade-out, 300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;
4+
}
5+
</style>

0 commit comments

Comments
 (0)