css_visitors.RelativeSelector() — svelte Function Reference
Architecture documentation for the css_visitors.RelativeSelector() function in css-analyze.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD d1dd9e5c_4841_1fec_d668_b8510addbb86["css_visitors.RelativeSelector()"] ca006f7f_f554_f529_8a19_abaaa45dda8d["css-analyze.js"] d1dd9e5c_4841_1fec_d668_b8510addbb86 -->|defined in| ca006f7f_f554_f529_8a19_abaaa45dda8d dff4fce6_a04d_698c_eef1_f67b276d0b98["css_selector_invalid()"] d1dd9e5c_4841_1fec_d668_b8510addbb86 -->|calls| dff4fce6_a04d_698c_eef1_f67b276d0b98 e9b067fe_6d2b_e8a5_4273_6c0120e67111["is_global()"] d1dd9e5c_4841_1fec_d668_b8510addbb86 -->|calls| e9b067fe_6d2b_e8a5_4273_6c0120e67111 style d1dd9e5c_4841_1fec_d668_b8510addbb86 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js lines 142–196
RelativeSelector(node, context) {
const parent = /** @type {AST.CSS.ComplexSelector} */ (context.path.at(-1));
if (
node.combinator != null &&
!context.state.rule?.metadata.parent_rule &&
parent.children[0] === node &&
context.path.at(-3)?.type !== 'PseudoClassSelector'
) {
e.css_selector_invalid(node.combinator);
}
node.metadata.is_global = node.selectors.length >= 1 && is_global(node);
if (
node.selectors.length >= 1 &&
node.selectors.every(
(selector) =>
selector.type === 'PseudoClassSelector' || selector.type === 'PseudoElementSelector'
)
) {
const first = node.selectors[0];
node.metadata.is_global_like ||=
(first.type === 'PseudoClassSelector' && first.name === 'host') ||
(first.type === 'PseudoElementSelector' &&
[
'view-transition',
'view-transition-group',
'view-transition-old',
'view-transition-new',
'view-transition-image-pair'
].includes(first.name));
}
node.metadata.is_global_like ||=
node.selectors.some(
(child) => child.type === 'PseudoClassSelector' && child.name === 'root'
) &&
// :root.y:has(.x) is not a global selector because while .y is unscoped, .x inside `:has(...)` should be scoped
!node.selectors.some((child) => child.type === 'PseudoClassSelector' && child.name === 'has');
if (node.metadata.is_global_like || node.metadata.is_global) {
// So that nested selectors like `:root:not(.x)` are not marked as unused
for (const child of node.selectors) {
walk(/** @type {AST.CSS.Node} */ (child), null, {
ComplexSelector(node, context) {
node.metadata.used = true;
context.next();
}
});
}
}
context.next();
},
Domain
Subdomains
Source
Frequently Asked Questions
What does css_visitors.RelativeSelector() do?
css_visitors.RelativeSelector() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js.
Where is css_visitors.RelativeSelector() defined?
css_visitors.RelativeSelector() is defined in packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js at line 142.
What does css_visitors.RelativeSelector() call?
css_visitors.RelativeSelector() calls 2 function(s): css_selector_invalid, is_global.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free