Home / Function/ is_global() — svelte Function Reference

is_global() — svelte Function Reference

Architecture documentation for the is_global() function in css-prune.js from the svelte codebase.

Function javascript Compiler Analyzer calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  1092183f_deda_3e7f_c2d9_d945fa5bbecb["is_global()"]
  cb1bf043_dade_7352_cc2b_976ffa2968d8["css-prune.js"]
  1092183f_deda_3e7f_c2d9_d945fa5bbecb -->|defined in| cb1bf043_dade_7352_cc2b_976ffa2968d8
  a482078a_f217_b205_783e_29603b509866["apply_combinator()"]
  a482078a_f217_b205_783e_29603b509866 -->|calls| 1092183f_deda_3e7f_c2d9_d945fa5bbecb
  44fb7f7e_7a78_eedb_fde3_53e386135788["relative_selector_might_apply_to_node()"]
  44fb7f7e_7a78_eedb_fde3_53e386135788 -->|calls| 1092183f_deda_3e7f_c2d9_d945fa5bbecb
  e9b067fe_6d2b_e8a5_4273_6c0120e67111["is_global()"]
  1092183f_deda_3e7f_c2d9_d945fa5bbecb -->|calls| e9b067fe_6d2b_e8a5_4273_6c0120e67111
  de2c7a90_dcc5_7509_ecb3_b33884f394c9["is_unscoped_pseudo_class()"]
  1092183f_deda_3e7f_c2d9_d945fa5bbecb -->|calls| de2c7a90_dcc5_7509_ecb3_b33884f394c9
  style 1092183f_deda_3e7f_c2d9_d945fa5bbecb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js lines 296–335

function is_global(selector, rule) {
	if (selector.metadata.is_global || selector.metadata.is_global_like) {
		return true;
	}

	let explicitly_global = false;

	for (const s of selector.selectors) {
		/** @type {Compiler.AST.CSS.SelectorList | null} */
		let selector_list = null;
		let can_be_global = false;
		let owner = rule;

		if (s.type === 'PseudoClassSelector') {
			if ((s.name === 'is' || s.name === 'where') && s.args) {
				selector_list = s.args;
			} else {
				can_be_global = is_unscoped_pseudo_class(s);
			}
		}

		if (s.type === 'NestingSelector') {
			owner = /** @type {Compiler.AST.CSS.Rule} */ (rule.metadata.parent_rule);
			selector_list = owner.prelude;
		}

		const has_global_selectors = !!selector_list?.children.some((complex_selector) => {
			return complex_selector.children.every((relative_selector) =>
				is_global(relative_selector, owner)
			);
		});
		explicitly_global ||= has_global_selectors;

		if (!has_global_selectors && !can_be_global) {
			return false;
		}
	}

	return explicitly_global || selector.selectors.length === 0;
}

Domain

Subdomains

Frequently Asked Questions

What does is_global() do?
is_global() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js.
Where is is_global() defined?
is_global() is defined in packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js at line 296.
What does is_global() call?
is_global() calls 2 function(s): is_global, is_unscoped_pseudo_class.
What calls is_global()?
is_global() is called by 2 function(s): apply_combinator, relative_selector_might_apply_to_node.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free