BindDirective.js — svelte Source File
Architecture documentation for BindDirective.js, a javascript file in the svelte codebase. 11 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR f59848c5_33bd_24cb_c787_66ccdd8d5b5e["BindDirective.js"] 62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6 7a7783f8_ffa6_0cc3_61b0_031882649535["is_ignored"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 7a7783f8_ffa6_0cc3_61b0_031882649535 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c 653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 653284b2_68fd_eee3_0064_918a4c065d4a 70f59999_db72_c4f6_2b0c_4234646f3763["bindings.js"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 70f59999_db72_c4f6_2b0c_4234646f3763 7880f852_1b7b_9ea3_4e22_732f4a684bbe["element.js"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 7880f852_1b7b_9ea3_4e22_732f4a684bbe e31bc2c2_91c1_b9a9_f78a_2832bddce6c5["build_attribute_value"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> e31bc2c2_91c1_b9a9_f78a_2832bddce6c5 d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> d04d7971_88df_542d_dd4f_26170ce6f581 8027aa4e_4fda_68d8_71fa_0a45b97acb64["build_bind_this"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 8027aa4e_4fda_68d8_71fa_0a45b97acb64 6922c44b_14fe_b017_d157_304290a82a06["validate_binding"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 6922c44b_14fe_b017_d157_304290a82a06 95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"] f59848c5_33bd_24cb_c787_66ccdd8d5b5e --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc 7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"] 7665e008_f37d_b860_a594_f2539a66af4e --> f59848c5_33bd_24cb_c787_66ccdd8d5b5e style f59848c5_33bd_24cb_c787_66ccdd8d5b5e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { CallExpression, Expression, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import { dev, is_ignored } from '../../../../state.js';
import { is_text_attribute } from '../../../../utils/ast.js';
import * as b from '#compiler/builders';
import { binding_properties } from '../../../bindings.js';
import { build_attribute_value } from './shared/element.js';
import { build_bind_this, validate_binding } from './shared/utils.js';
/**
* @param {AST.BindDirective} node
* @param {ComponentContext} context
*/
export function BindDirective(node, context) {
const expression = /** @type {Expression} */ (context.visit(node.expression));
const property = binding_properties[node.name];
const parent = /** @type {AST.SvelteNode} */ (context.path.at(-1));
let get, set;
if (expression.type === 'SequenceExpression') {
[get, set] = expression.expressions;
} else {
if (
dev &&
context.state.analysis.runes &&
expression.type === 'MemberExpression' &&
(node.name !== 'this' ||
context.path.some(
({ type }) =>
type === 'IfBlock' ||
type === 'EachBlock' ||
type === 'AwaitBlock' ||
type === 'KeyBlock'
)) &&
!is_ignored(node, 'binding_property_non_reactive')
) {
validate_binding(context.state, node, expression);
}
const assignment = /** @type {Expression} */ (
context.visit(b.assignment('=', /** @type {Pattern} */ (node.expression), b.id('$$value')))
);
if (dev) {
// in dev, create named functions, so that `$inspect(...)` delivers
// useful stack traces
get = b.function(b.id('get', node.name_loc), [], b.block([b.return(expression)]));
set = b.function(
b.id('set', node.name_loc),
[b.id('$$value')],
b.block([b.stmt(assignment)])
);
} else {
// in prod, optimise for brevity
get = b.thunk(expression);
/** @type {Expression | undefined} */
// ... (231 more lines)
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does BindDirective.js do?
BindDirective.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 BindDirective.js?
BindDirective.js defines 1 function(s): BindDirective.
What does BindDirective.js depend on?
BindDirective.js imports 11 module(s): ast.js, bindings.js, build_attribute_value, build_bind_this, builders, element.js, is_ignored, is_text_attribute, and 3 more.
What files import BindDirective.js?
BindDirective.js is imported by 1 file(s): transform-client.js.
Where is BindDirective.js in the architecture?
BindDirective.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free