Skip to content

Commit 227729e

Browse files
committed
tweak
1 parent 77befcf commit 227729e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ const css_visitors = {
113113

114114
node.metadata.rule = context.state.rule;
115115

116-
node.metadata.used ||= node.children.every(
116+
node.metadata.is_global = node.children.every(
117117
({ metadata }) => metadata.is_global || metadata.is_global_like
118118
);
119119

120+
node.metadata.used ||= node.metadata.is_global;
121+
120122
if (
121123
node.metadata.rule?.metadata.parent_rule &&
122124
node.children[0]?.selectors[0]?.type === 'NestingSelector'
@@ -262,13 +264,10 @@ const css_visitors = {
262264
// visit selector list first, to populate child selector metadata
263265
context.visit(node.prelude, state);
264266

265-
node.metadata.has_global_selectors = node.prelude.children.some((selector) =>
266-
selector.children.every(({ metadata }) => metadata.is_global || metadata.is_global_like)
267-
);
268-
269-
node.metadata.has_local_selectors = node.prelude.children.some((selector) =>
270-
selector.children.some(({ metadata }) => !metadata.is_global && !metadata.is_global_like)
271-
);
267+
for (const selector of node.prelude.children) {
268+
node.metadata.has_global_selectors ||= selector.metadata.is_global;
269+
node.metadata.has_local_selectors ||= !selector.metadata.is_global;
270+
}
272271

273272
// if this rule has a ComplexSelector whose RelativeSelector children are all
274273
// `:global(...)`, and the rule contains declarations (rather than just

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export namespace _CSS {
6868
/** @internal */
6969
metadata: {
7070
rule: null | Rule;
71+
is_global: boolean;
7172
/** True if this selector applies to an element. For global selectors, this is defined in css-analyze, for others in css-prune while scoping */
7273
used: boolean;
7374
};

0 commit comments

Comments
 (0)