Home / File/ css.js — svelte Source File

css.js — svelte Source File

Architecture documentation for css.js, a javascript file in the svelte codebase. 5 imports, 0 dependents.

File javascript ClientRuntime Hydration 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  dd87479e_8330_8a43_936a_83ad4324992e["css.js"]
  33e08b1f_4e66_1857_fa57_0463c957ec07["css.js"]
  dd87479e_8330_8a43_936a_83ad4324992e --> 33e08b1f_4e66_1857_fa57_0463c957ec07
  b41287eb_7238_7aeb_ba63_1acdf7f7f950["register_style"]
  dd87479e_8330_8a43_936a_83ad4324992e --> b41287eb_7238_7aeb_ba63_1acdf7f7f950
  1ae6fa4e_16ee_acdf_5e28_17eb0819fddb["effects.js"]
  dd87479e_8330_8a43_936a_83ad4324992e --> 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb
  a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect"]
  dd87479e_8330_8a43_936a_83ad4324992e --> a985ae40_8ef8_7ef2_adad_116fbf97e70c
  c9866d91_a204_fa55_a9e3_6bcc6aaaec1e["esm-env"]
  dd87479e_8330_8a43_936a_83ad4324992e --> c9866d91_a204_fa55_a9e3_6bcc6aaaec1e
  style dd87479e_8330_8a43_936a_83ad4324992e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { DEV } from 'esm-env';
import { register_style } from '../dev/css.js';
import { effect } from '../reactivity/effects.js';

/**
 * @param {Node} anchor
 * @param {{ hash: string, code: string }} css
 */
export function append_styles(anchor, css) {
	// Use `queue_micro_task` to ensure `anchor` is in the DOM, otherwise getRootNode() will yield wrong results
	effect(() => {
		var root = anchor.getRootNode();

		var target = /** @type {ShadowRoot} */ (root).host
			? /** @type {ShadowRoot} */ (root)
			: /** @type {Document} */ (root).head ?? /** @type {Document} */ (root.ownerDocument).head;

		// Always querying the DOM is roughly the same perf as additionally checking for presence in a map first assuming
		// that you'll get cache hits half of the time, so we just always query the dom for simplicity and code savings.
		if (!target.querySelector('#' + css.hash)) {
			const style = document.createElement('style');
			style.id = css.hash;
			style.textContent = css.code;

			target.appendChild(style);

			if (DEV) {
				register_style(css.hash, style);
			}
		}
	});
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does css.js do?
css.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in css.js?
css.js defines 1 function(s): append_styles.
What does css.js depend on?
css.js imports 5 module(s): css.js, effect, effects.js, esm-env, register_style.
Where is css.js in the architecture?
css.js is located at packages/svelte/src/internal/client/dom/css.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom).

Analyze Your Own Codebase

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

Try Supermodel Free