Skip to content

Commit 76371f7

Browse files
committed
reduce indirection
1 parent dc4330c commit 76371f7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { is_global, is_unscoped_pseudo_class } from './utils.js';
1010
* @typedef {{
1111
* keyframes: string[];
1212
* rule: AST.CSS.Rule | null;
13-
* has_global: { value: boolean }; // need an object since state is spread
13+
* analysis: ComponentAnalysis;
1414
* }} CssState
1515
*/
1616

@@ -57,7 +57,7 @@ const css_visitors = {
5757
context.state.keyframes.push(node.prelude);
5858
} else if (node.prelude.startsWith('-global-')) {
5959
// we don't check if the block.children.length because the keyframe is still added even if empty
60-
context.state.has_global.value ||= is_unscoped(context.path);
60+
context.state.analysis.css.has_global ||= is_unscoped(context.path);
6161
}
6262
}
6363

@@ -276,7 +276,7 @@ const css_visitors = {
276276
// if this rule has a ComplexSelector whose RelativeSelector children are all
277277
// `:global(...)`, and the rule contains declarations (rather than just
278278
// nested rules) then the component as a whole includes global CSS
279-
context.state.has_global.value ||=
279+
context.state.analysis.css.has_global ||=
280280
node.metadata.has_global_selectors &&
281281
node.block.children.filter((child) => child.type === 'Declaration').length > 0 &&
282282
is_unscoped(context.path);
@@ -324,10 +324,8 @@ export function analyze_css(stylesheet, analysis) {
324324
const css_state = {
325325
keyframes: analysis.css.keyframes,
326326
rule: null,
327-
// we need to use an object since state is spread
328-
has_global: { value: false }
327+
analysis
329328
};
330329

331330
walk(stylesheet, css_state, css_visitors);
332-
analysis.css.has_global = css_state.has_global.value;
333331
}

0 commit comments

Comments
 (0)