attribute.js — svelte Source File
Architecture documentation for attribute.js, a javascript file in the svelte codebase. 9 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 32df1fa2_adf7_5122_0b02_c399ea508ae0["attribute.js"] 495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218 a146f6ac_0088_8736_b6ce_318f9f115170["e"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> a146f6ac_0088_8736_b6ce_318f9f115170 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c 653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 653284b2_68fd_eee3_0064_918a4c065d4a 56a689f9_11c0_cc76_bd60_41bb6dc96475["warnings.js"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 56a689f9_11c0_cc76_bd60_41bb6dc96475 3246e0bc_b9fc_f638_5e35_41e8c39a2408["w"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 3246e0bc_b9fc_f638_5e35_41e8c39a2408 bbca3d2a_42c8_b215_d3b5_5077ccaf0797["nodes.js"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797 76437ce7_73fa_a7f2_397a_1ddd381e8282["is_custom_element_node"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> 76437ce7_73fa_a7f2_397a_1ddd381e8282 ce051dbd_4cf1_f117_d66e_12cfa122de37["patterns.js"] 32df1fa2_adf7_5122_0b02_c399ea508ae0 --> ce051dbd_4cf1_f117_d66e_12cfa122de37 f2ad80e0_97e0_ac48_aec8_8b70c646ca26["SvelteFragment.js"] f2ad80e0_97e0_ac48_aec8_8b70c646ca26 --> 32df1fa2_adf7_5122_0b02_c399ea508ae0 057ad110_57ab_942c_4f8d_5c2f711bef54["component.js"] 057ad110_57ab_942c_4f8d_5c2f711bef54 --> 32df1fa2_adf7_5122_0b02_c399ea508ae0 bab84a6b_4a21_0643_e6ee_13798dfa8b84["element.js"] bab84a6b_4a21_0643_e6ee_13798dfa8b84 --> 32df1fa2_adf7_5122_0b02_c399ea508ae0 style 32df1fa2_adf7_5122_0b02_c399ea508ae0 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 { is_text_attribute } from '../../../../utils/ast.js';
import * as w from '../../../../warnings.js';
import { is_custom_element_node } from '../../../nodes.js';
import { regex_only_whitespaces } from '../../../patterns.js';
/**
* @param {AST.Attribute} attribute
*/
export function validate_attribute_name(attribute) {
if (
attribute.name.includes(':') &&
!attribute.name.startsWith('xmlns:') &&
!attribute.name.startsWith('xlink:') &&
!attribute.name.startsWith('xml:')
) {
w.attribute_illegal_colon(attribute);
}
}
/**
* @param {AST.Attribute} attribute
* @param {AST.ElementLike} parent
*/
export function validate_attribute(attribute, parent) {
if (
Array.isArray(attribute.value) &&
attribute.value.length === 1 &&
attribute.value[0].type === 'ExpressionTag' &&
(parent.type === 'Component' ||
parent.type === 'SvelteComponent' ||
parent.type === 'SvelteSelf' ||
(parent.type === 'RegularElement' && is_custom_element_node(parent)))
) {
w.attribute_quoted(attribute);
}
if (attribute.value === true || !Array.isArray(attribute.value) || attribute.value.length === 1) {
return;
}
const is_quoted = attribute.value.at(-1)?.end !== attribute.end;
if (!is_quoted) {
e.attribute_unquoted_sequence(attribute);
}
}
/**
* @param {Context} context
* @param {AST.Attribute} attribute
* @param {boolean} is_component
*/
export function validate_slot_attribute(context, attribute, is_component = false) {
const parent = context.path.at(-2);
let owner = undefined;
if (parent?.type === 'SnippetBlock') {
// ... (66 more lines)
Domain
Subdomains
Imported By
Source
Frequently Asked Questions
What does attribute.js do?
attribute.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 attribute.js?
attribute.js defines 3 function(s): validate_attribute, validate_attribute_name, validate_slot_attribute.
What does attribute.js depend on?
attribute.js imports 9 module(s): ast.js, e, errors.js, is_custom_element_node, is_text_attribute, nodes.js, patterns.js, w, and 1 more.
What files import attribute.js?
attribute.js is imported by 3 file(s): SvelteFragment.js, component.js, element.js.
Where is attribute.js in the architecture?
attribute.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free