Home / Function/ is_static_element() — svelte Function Reference

is_static_element() — svelte Function Reference

Architecture documentation for the is_static_element() function in fragment.js from the svelte codebase.

Function javascript Compiler Transformer calls 4 called by 2

Entity Profile

Dependency Diagram

graph TD
  9ed24ec7_b6a7_48e2_39ec_d718faf36705["is_static_element()"]
  2d9685c3_3dc6_7a1f_823b_1e70d1834927["fragment.js"]
  9ed24ec7_b6a7_48e2_39ec_d718faf36705 -->|defined in| 2d9685c3_3dc6_7a1f_823b_1e70d1834927
  1e3b81f2_cd53_e5a5_0140_a9af38facf99["RegularElement()"]
  1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 9ed24ec7_b6a7_48e2_39ec_d718faf36705
  b52df138_fa9e_4e12_86dd_c455789e68c1["process_children()"]
  b52df138_fa9e_4e12_86dd_c455789e68c1 -->|calls| 9ed24ec7_b6a7_48e2_39ec_d718faf36705
  76437ce7_73fa_a7f2_397a_1ddd381e8282["is_custom_element_node()"]
  9ed24ec7_b6a7_48e2_39ec_d718faf36705 -->|calls| 76437ce7_73fa_a7f2_397a_1ddd381e8282
  e9a2c29e_d0ca_ab9f_b86f_f22ff802db91["is_event_attribute()"]
  9ed24ec7_b6a7_48e2_39ec_d718faf36705 -->|calls| e9a2c29e_d0ca_ab9f_b86f_f22ff802db91
  236530b5_f75d_4a7b_e916_b2d6a6d54dfb["cannot_be_set_statically()"]
  9ed24ec7_b6a7_48e2_39ec_d718faf36705 -->|calls| 236530b5_f75d_4a7b_e916_b2d6a6d54dfb
  653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute()"]
  9ed24ec7_b6a7_48e2_39ec_d718faf36705 -->|calls| 653284b2_68fd_eee3_0064_918a4c065d4a
  style 9ed24ec7_b6a7_48e2_39ec_d718faf36705 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js lines 141–185

export function is_static_element(node) {
	if (node.type !== 'RegularElement') return false;
	if (node.fragment.metadata.dynamic) return false;
	if (is_custom_element_node(node)) return false; // we're setting all attributes on custom elements through properties

	for (const attribute of node.attributes) {
		if (attribute.type !== 'Attribute') {
			return false;
		}

		if (is_event_attribute(attribute)) {
			return false;
		}

		if (cannot_be_set_statically(attribute.name)) {
			return false;
		}

		if (attribute.name === 'dir') {
			return false;
		}

		if (
			['input', 'textarea'].includes(node.name) &&
			['value', 'checked'].includes(attribute.name)
		) {
			return false;
		}

		if (node.name === 'option' && attribute.name === 'value') {
			return false;
		}

		// We need to apply src and loading after appending the img to the DOM for lazy loading to work
		if (node.name === 'img' && attribute.name === 'loading') {
			return false;
		}

		if (attribute.value !== true && !is_text_attribute(attribute)) {
			return false;
		}
	}

	return true;
}

Domain

Subdomains

Frequently Asked Questions

What does is_static_element() do?
is_static_element() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js.
Where is is_static_element() defined?
is_static_element() is defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js at line 141.
What does is_static_element() call?
is_static_element() calls 4 function(s): cannot_be_set_statically, is_custom_element_node, is_event_attribute, is_text_attribute.
What calls is_static_element()?
is_static_element() is called by 2 function(s): RegularElement, process_children.

Analyze Your Own Codebase

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

Try Supermodel Free