select.js — svelte Source File
Architecture documentation for select.js, a javascript file in the svelte codebase. 11 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc["select.js"] 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb["effects.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> a985ae40_8ef8_7ef2_adad_116fbf97e70c 20340432_01a2_6741_abf4_60ccab51cdb3["teardown"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> 20340432_01a2_6741_abf4_60ccab51cdb3 af7441d2_339a_2db1_88df_90dba2875c10["shared.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> af7441d2_339a_2db1_88df_90dba2875c10 140e2114_da40_4679_bc9f_599a89c67e4e["listen_to_event_and_reset_event"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> 140e2114_da40_4679_bc9f_599a89c67e4e 71020d3b_ab64_9fea_2a06_dab93412f92f["proxy.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> 71020d3b_ab64_9fea_2a06_dab93412f92f e604925d_22aa_7ddd_2399_07b188b31eb1["is"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> e604925d_22aa_7ddd_2399_07b188b31eb1 cb946435_ce66_d1e8_6bee_287bdb07e7c5["utils.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> cb946435_ce66_d1e8_6bee_287bdb07e7c5 df278ca2_0a6c_fefe_09f2_b397500fe3c2["warnings.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> df278ca2_0a6c_fefe_09f2_b397500fe3c2 d8e42d9d_2e3c_635c_19d3_b946a4341c0f["batch.js"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> d8e42d9d_2e3c_635c_19d3_b946a4341c0f 517c145b_769f_b163_6854_d8f2a4412e11["Batch"] dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc --> 517c145b_769f_b163_6854_d8f2a4412e11 0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"] 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc style dbe1ea86_6e94_eeeb_a2d1_1db78ca967bc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { effect, teardown } from '../../../reactivity/effects.js';
import { listen_to_event_and_reset_event } from './shared.js';
import { is } from '../../../proxy.js';
import { is_array } from '../../../../shared/utils.js';
import * as w from '../../../warnings.js';
import { Batch, current_batch, previous_batch } from '../../../reactivity/batch.js';
/**
* Selects the correct option(s) (depending on whether this is a multiple select)
* @template V
* @param {HTMLSelectElement} select
* @param {V} value
* @param {boolean} mounting
*/
export function select_option(select, value, mounting = false) {
if (select.multiple) {
// If value is null or undefined, keep the selection as is
if (value == undefined) {
return;
}
// If not an array, warn and keep the selection as is
if (!is_array(value)) {
return w.select_multiple_invalid_value();
}
// Otherwise, update the selection
for (var option of select.options) {
option.selected = value.includes(get_option_value(option));
}
return;
}
for (option of select.options) {
var option_value = get_option_value(option);
if (is(option_value, value)) {
option.selected = true;
return;
}
}
if (!mounting || value !== undefined) {
select.selectedIndex = -1; // no option should be selected
}
}
/**
* Selects the correct option(s) if `value` is given,
* and then sets up a mutation observer to sync the
* current selection to the dom when it changes. Such
* changes could for example occur when options are
* inside an `#each` block.
* @param {HTMLSelectElement} select
*/
export function init_select(select) {
var observer = new MutationObserver(() => {
// @ts-ignore
select_option(select, select.__value);
// Deliberately don't update the potential binding value,
// ... (100 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does select.js do?
select.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 select.js?
select.js defines 4 function(s): bind_select_value, get_option_value, init_select, select_option.
What does select.js depend on?
select.js imports 11 module(s): Batch, batch.js, effect, effects.js, is, listen_to_event_and_reset_event, proxy.js, shared.js, and 3 more.
What files import select.js?
select.js is imported by 1 file(s): attributes.js.
Where is select.js in the architecture?
select.js is located at packages/svelte/src/internal/client/dom/elements/bindings/select.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