Home / File/ StyleDirective.js — svelte Source File

StyleDirective.js — svelte Source File

Architecture documentation for StyleDirective.js, a javascript file in the svelte codebase. 6 imports, 1 dependents.

File javascript Compiler Transformer 6 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  f78b6bee_5963_5e6b_4d2b_199d03083df8["StyleDirective.js"]
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> a146f6ac_0088_8736_b6ce_318f9f115170
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  f6625393_617b_8f3b_aaa5_b87527fde52f["get_attribute_chunks"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> f6625393_617b_8f3b_aaa5_b87527fde52f
  c4b4ac8d_9914_5ede_1aea_723bf80d2e9b["fragment.js"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> c4b4ac8d_9914_5ede_1aea_723bf80d2e9b
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic"]
  f78b6bee_5963_5e6b_4d2b_199d03083df8 --> 313d2a82_30ea_3161_3aad_0cc2094979aa
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> f78b6bee_5963_5e6b_4d2b_199d03083df8
  style f78b6bee_5963_5e6b_4d2b_199d03083df8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import * as e from '../../../errors.js';
import { get_attribute_chunks } from '../../../utils/ast.js';
import { mark_subtree_dynamic } from './shared/fragment.js';

/**
 * @param {AST.StyleDirective} node
 * @param {Context} context
 */
export function StyleDirective(node, context) {
	if (node.modifiers.length > 1 || (node.modifiers.length && node.modifiers[0] !== 'important')) {
		e.style_directive_invalid_modifier(node);
	}

	mark_subtree_dynamic(context.path);

	if (node.value === true) {
		// get the binding for node.name and change the binding to state
		let binding = context.state.scope.get(node.name);

		if (binding) {
			if (binding.kind !== 'normal') {
				node.metadata.expression.has_state = true;
			}
			if (binding.blocker) {
				node.metadata.expression.dependencies.add(binding);
			}
		}
	} else {
		context.next();

		for (const chunk of get_attribute_chunks(node.value)) {
			if (chunk.type !== 'ExpressionTag') continue;

			node.metadata.expression.merge(chunk.metadata.expression);
		}
	}
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does StyleDirective.js do?
StyleDirective.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in StyleDirective.js?
StyleDirective.js defines 1 function(s): StyleDirective.
What does StyleDirective.js depend on?
StyleDirective.js imports 6 module(s): ast.js, e, errors.js, fragment.js, get_attribute_chunks, mark_subtree_dynamic.
What files import StyleDirective.js?
StyleDirective.js is imported by 1 file(s): index.js.
Where is StyleDirective.js in the architecture?
StyleDirective.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/StyleDirective.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free