Home / File/ attributes.js — svelte Source File

attributes.js — svelte Source File

Architecture documentation for attributes.js, a javascript file in the svelte codebase. 41 imports, 0 dependents.

File javascript ClientRuntime Hydration 41 imports 17 functions

Entity Profile

Dependency Diagram

graph LR
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"]
  f3948b0d_b92a_0767_ba6c_832767f4e2bb["hydration.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> f3948b0d_b92a_0767_ba6c_832767f4e2bb
  f5b61c69_d41c_bdb7_b931_5b8b3374332c["set_hydrating"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> f5b61c69_d41c_bdb7_b931_5b8b3374332c
  cb946435_ce66_d1e8_6bee_287bdb07e7c5["utils.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> cb946435_ce66_d1e8_6bee_287bdb07e7c5
  2c990bd1_acff_5910_3af2_ab75f655b31b["events.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 2c990bd1_acff_5910_3af2_ab75f655b31b
  12245a28_3cec_3119_faa7_968496e0db88["create_event"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 12245a28_3cec_3119_faa7_968496e0db88
  2d5290be_7d59_5095_a533_c737cb75a0a4["delegate"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 2d5290be_7d59_5095_a533_c737cb75a0a4
  56e684d7_8156_2bdf_6537_717e59d1e537["misc.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 56e684d7_8156_2bdf_6537_717e59d1e537
  f331da79_3d16_9f30_3a8b_0b6cd7a6de51["add_form_reset_listener"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> f331da79_3d16_9f30_3a8b_0b6cd7a6de51
  881d60c0_047b_ad82_2c37_19eec36960d9["autofocus"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 881d60c0_047b_ad82_2c37_19eec36960d9
  df278ca2_0a6c_fefe_09f2_b397500fe3c2["warnings.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> df278ca2_0a6c_fefe_09f2_b397500fe3c2
  8e9a8b22_9754_09a3_8bf1_af0aeb68deca["task.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 8e9a8b22_9754_09a3_8bf1_af0aeb68deca
  2cab0f64_6d19_d981_66e2_d2555c252702["queue_micro_task"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 2cab0f64_6d19_d981_66e2_d2555c252702
  2aa63f4e_82c9_33e3_ac6c_5f3d46250522["utils.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  414b9ea2_b052_6759_fdfb_f4cabf75669c["is_capture_event"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> 414b9ea2_b052_6759_fdfb_f4cabf75669c
  style 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Blocker, Effect } from '#client' */
import { DEV } from 'esm-env';
import { hydrating, set_hydrating } from '../hydration.js';
import { get_descriptors, get_prototype_of } from '../../../shared/utils.js';
import { create_event, delegate } from './events.js';
import { add_form_reset_listener, autofocus } from './misc.js';
import * as w from '../../warnings.js';
import { LOADING_ATTR_SYMBOL } from '#client/constants';
import { queue_micro_task } from '../task.js';
import { is_capture_event, can_delegate_event, normalize_attribute } from '../../../../utils.js';
import {
	active_effect,
	active_reaction,
	get,
	set_active_effect,
	set_active_reaction
} from '../../runtime.js';
import { attach } from './attachments.js';
import { clsx } from '../../../shared/attributes.js';
import { set_class } from './class.js';
import { set_style } from './style.js';
import { ATTACHMENT_KEY, NAMESPACE_HTML, UNINITIALIZED } from '../../../../constants.js';
import { branch, destroy_effect, effect, managed } from '../../reactivity/effects.js';
import { init_select, select_option } from './bindings/select.js';
import { flatten } from '../../reactivity/async.js';

export const CLASS = Symbol('class');
export const STYLE = Symbol('style');

const IS_CUSTOM_ELEMENT = Symbol('is custom element');
const IS_HTML = Symbol('is html');

/**
 * The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
 * to remove it upon hydration to avoid a bug when someone resets the form value.
 * @param {HTMLInputElement} input
 * @returns {void}
 */
export function remove_input_defaults(input) {
	if (!hydrating) return;

	var already_removed = false;

	// We try and remove the default attributes later, rather than sync during hydration.
	// Doing it sync during hydration has a negative impact on performance, but deferring the
	// work in an idle task alleviates this greatly. If a form reset event comes in before
	// the idle callback, then we ensure the input defaults are cleared just before.
	var remove_defaults = () => {
		if (already_removed) return;
		already_removed = true;

		// Remove the attributes but preserve the values
		if (input.hasAttribute('value')) {
			var value = input.value;
			set_attribute(input, 'value', null);
			input.value = value;
		}

		if (input.hasAttribute('checked')) {
			var checked = input.checked;
// ... (598 more lines)

Domain

Subdomains

Frequently Asked Questions

What does attributes.js do?
attributes.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 attributes.js?
attributes.js defines 17 function(s): attribute_effect, check_src_in_dev_hydration, get_attributes, get_setters, remove_input_defaults, set_attribute, set_attributes, set_checked, set_custom_element_data, set_default_checked, and 7 more.
What does attributes.js depend on?
attributes.js imports 41 module(s): add_form_reset_listener, async.js, attach, attachments.js, attributes.js, autofocus, branch, can_delegate_event, and 33 more.
Where is attributes.js in the architecture?
attributes.js is located at packages/svelte/src/internal/client/dom/elements/attributes.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/elements).

Analyze Your Own Codebase

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

Try Supermodel Free