input.js — svelte Source File
Architecture documentation for input.js, a javascript file in the svelte codebase. 18 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2254d980_5794_d0a4_3609_60f21d662ff4["input.js"] 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb["effects.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb 7494b934_a3b8_689e_91b6_8435e26461c5["render_effect"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 7494b934_a3b8_689e_91b6_8435e26461c5 20340432_01a2_6741_abf4_60ccab51cdb3["teardown"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 20340432_01a2_6741_abf4_60ccab51cdb3 af7441d2_339a_2db1_88df_90dba2875c10["shared.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> af7441d2_339a_2db1_88df_90dba2875c10 140e2114_da40_4679_bc9f_599a89c67e4e["listen_to_event_and_reset_event"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 140e2114_da40_4679_bc9f_599a89c67e4e ff387d97_d6d2_81e0_e731_656552709d27["errors.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> ff387d97_d6d2_81e0_e731_656552709d27 71020d3b_ab64_9fea_2a06_dab93412f92f["proxy.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 71020d3b_ab64_9fea_2a06_dab93412f92f e604925d_22aa_7ddd_2399_07b188b31eb1["is"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> e604925d_22aa_7ddd_2399_07b188b31eb1 8e9a8b22_9754_09a3_8bf1_af0aeb68deca["task.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 8e9a8b22_9754_09a3_8bf1_af0aeb68deca 2cab0f64_6d19_d981_66e2_d2555c252702["queue_micro_task"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> 2cab0f64_6d19_d981_66e2_d2555c252702 f3948b0d_b92a_0767_ba6c_832767f4e2bb["hydration.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> f3948b0d_b92a_0767_ba6c_832767f4e2bb bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> bde4209f_8ffc_1594_4024_b1835a44bcf6 a53cae39_471c_2887_0e0b_eedb385d245a["tick"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> a53cae39_471c_2887_0e0b_eedb385d245a a814b193_e12a_4037_c3c8_dfd45f3bd0bb["untrack"] 2254d980_5794_d0a4_3609_60f21d662ff4 --> a814b193_e12a_4037_c3c8_dfd45f3bd0bb style 2254d980_5794_d0a4_3609_60f21d662ff4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { Batch } from '../../../reactivity/batch.js' */
import { DEV } from 'esm-env';
import { render_effect, teardown } from '../../../reactivity/effects.js';
import { listen_to_event_and_reset_event } from './shared.js';
import * as e from '../../../errors.js';
import { is } from '../../../proxy.js';
import { queue_micro_task } from '../../task.js';
import { hydrating } from '../../hydration.js';
import { tick, untrack } from '../../../runtime.js';
import { is_runes } from '../../../context.js';
import { current_batch, previous_batch } from '../../../reactivity/batch.js';
/**
* @param {HTMLInputElement} input
* @param {() => unknown} get
* @param {(value: unknown) => void} set
* @returns {void}
*/
export function bind_value(input, get, set = get) {
var batches = new WeakSet();
listen_to_event_and_reset_event(input, 'input', async (is_reset) => {
if (DEV && input.type === 'checkbox') {
// TODO should this happen in prod too?
e.bind_invalid_checkbox_value();
}
/** @type {any} */
var value = is_reset ? input.defaultValue : input.value;
value = is_numberlike_input(input) ? to_number(value) : value;
set(value);
if (current_batch !== null) {
batches.add(current_batch);
}
// Because `{#each ...}` blocks work by updating sources inside the flush,
// we need to wait a tick before checking to see if we should forcibly
// update the input and reset the selection state
await tick();
// Respect any validation in accessors
if (value !== (value = get())) {
var start = input.selectionStart;
var end = input.selectionEnd;
var length = input.value.length;
// the value is coerced on assignment
input.value = value ?? '';
// Restore selection
if (end !== null) {
var new_length = input.value.length;
// If cursor was at end and new input is longer, move cursor to new end
if (start === end && end === length && new_length > length) {
input.selectionStart = new_length;
input.selectionEnd = new_length;
} else {
input.selectionStart = start;
input.selectionEnd = Math.min(end, new_length);
// ... (253 more lines)
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does input.js do?
input.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in input.js?
input.js defines 7 function(s): bind_checked, bind_files, bind_group, bind_value, get_binding_group_value, is_numberlike_input, to_number.
What does input.js depend on?
input.js imports 18 module(s): batch.js, context.js, effects.js, errors.js, esm-env, hydration.js, is, is_runes, and 10 more.
Where is input.js in the architecture?
input.js is located at packages/svelte/src/internal/client/dom/elements/bindings/input.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/elements/bindings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free