Home / File/ nodes.js — svelte Source File

nodes.js — svelte Source File

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

File javascript Compiler Transformer 1 imports 29 dependents 7 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  bbca3d2a_42c8_b215_d3b5_5077ccaf0797["nodes.js"]
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  bbca3d2a_42c8_b215_d3b5_5077ccaf0797 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  367a364a_2912_a1aa_b2e1_d97a82783c38["tag.js"]
  367a364a_2912_a1aa_b2e1_d97a82783c38 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  8a5fbbc9_917f_c98f_cbca_9d2fe6ba5d72["types.d.ts"]
  8a5fbbc9_917f_c98f_cbca_9d2fe6ba5d72 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  3f0209c9_7af2_542f_1c9c_3be0eb046971["CallExpression.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  ae63a5f8_3bca_b89d_d2cc_a72104d95a3b["ClassBody.js"]
  ae63a5f8_3bca_b89d_d2cc_a72104d95a3b --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449["Identifier.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  2e7493dd_ba08_9071_5988_c50f0fd536d9["PropertyDefinition.js"]
  2e7493dd_ba08_9071_5988_c50f0fd536d9 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a["RegularElement.js"]
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  7dee3da2_976f_9ebe_d9d5_50ad37d6c6e1["RenderTag.js"]
  7dee3da2_976f_9ebe_d9d5_50ad37d6c6e1 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  32df1fa2_adf7_5122_0b02_c399ea508ae0["attribute.js"]
  32df1fa2_adf7_5122_0b02_c399ea508ae0 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  bf0d8f1b_17da_970d_bf44_fbcf099d5371["utils.js"]
  bf0d8f1b_17da_970d_bf44_fbcf099d5371 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  96ee438d_6c6f_9aff_59f4_d00e63e9d98c["AssignmentExpression.js"]
  96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  style bbca3d2a_42c8_b215_d3b5_5077ccaf0797 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Expression, PrivateIdentifier, SourceLocation } from 'estree' */
/** @import { AST, Binding } from '#compiler' */
import * as b from '#compiler/builders';

/**
 * All nodes that can appear elsewhere than the top level, have attributes and can contain children
 */
const element_nodes = [
	'SvelteElement',
	'RegularElement',
	'SvelteFragment',
	'Component',
	'SvelteComponent',
	'SvelteSelf',
	'SlotElement'
];

/**
 * Returns true for all nodes that can appear elsewhere than the top level, have attributes and can contain children
 * @param {AST.SvelteNode} node
 * @returns {node is AST.Component | AST.RegularElement | AST.SlotElement | AST.SvelteComponent | AST.SvelteElement | AST.SvelteFragment | AST.SvelteSelf}
 */
export function is_element_node(node) {
	return element_nodes.includes(node.type);
}

/**
 * Returns true for all component-like nodes
 * @param {AST.SvelteNode} node
 * @returns {node is AST.Component |  AST.SvelteComponent | AST.SvelteSelf}
 */
export function is_component_node(node) {
	return ['Component', 'SvelteComponent', 'SvelteSelf'].includes(node.type);
}

/**
 * @param {AST.RegularElement | AST.SvelteElement} node
 * @returns {boolean}
 */
export function is_custom_element_node(node) {
	return (
		node.type === 'RegularElement' &&
		(node.name.includes('-') ||
			node.attributes.some((attr) => attr.type === 'Attribute' && attr.name === 'is'))
	);
}

/**
 * @param {string} name
 * @param {SourceLocation | null} name_loc
 * @param {number} start
 * @param {number} end
 * @param {AST.Attribute['value']} value
 * @returns {AST.Attribute}
 */
export function create_attribute(name, name_loc, start, end, value) {
	return {
		type: 'Attribute',
		start,
		end,
// ... (199 more lines)

Domain

Subdomains

Dependencies

  • builders

Imported By

Frequently Asked Questions

What does nodes.js do?
nodes.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 nodes.js?
nodes.js defines 7 function(s): create_attribute, find_descendants, get_name, is_component_node, is_custom_element_node, is_customizable_select_element, is_element_node.
What does nodes.js depend on?
nodes.js imports 1 module(s): builders.
What files import nodes.js?
nodes.js is imported by 29 file(s): AssignmentExpression.js, AssignmentExpression.js, CallExpression.js, ClassBody.js, ClassBody.js, ClassBody.js, Identifier.js, PropertyDefinition.js, and 21 more.
Where is nodes.js in the architecture?
nodes.js is located at packages/svelte/src/compiler/phases/nodes.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases).

Analyze Your Own Codebase

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

Try Supermodel Free