Home / Function/ escape_html() — svelte Function Reference

escape_html() — svelte Function Reference

Architecture documentation for the escape_html() function in escaping.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  d6dfd043_7103_f2c7_aab3_9660fb0a5f75["escape_html()"]
  cb064307_faf7_de99_b8a6_9523086a7c01["escaping.js"]
  d6dfd043_7103_f2c7_aab3_9660fb0a5f75 -->|defined in| cb064307_faf7_de99_b8a6_9523086a7c01
  aa03984a_4f5e_a389_0597_87262d57992f["stringify()"]
  aa03984a_4f5e_a389_0597_87262d57992f -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  573f9041_7062_5e5d_80e6_7292990c13c5["build_set_class()"]
  573f9041_7062_5e5d_80e6_7292990c13c5 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  17370b4c_df64_f183_35da_1de383ea4963["build_element_attributes()"]
  17370b4c_df64_f183_35da_1de383ea4963 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  4ec029f0_bbf8_66de_0dbf_d15eef3e10a0["process_children()"]
  4ec029f0_bbf8_66de_0dbf_d15eef3e10a0 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  9f24c33c_da34_a132_f273_3ffd2f6e5cf8["build_attribute_value()"]
  9f24c33c_da34_a132_f273_3ffd2f6e5cf8 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  adfac89e_1481_1792_6d5f_97c23465f231["style_object_to_string()"]
  adfac89e_1481_1792_6d5f_97c23465f231 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  c1bf689f_9f15_267c_beab_8284da94d675["attr_class()"]
  c1bf689f_9f15_267c_beab_8284da94d675 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  d261eea5_e3b2_bab9_63a0_198a8131668f["attr_style()"]
  d261eea5_e3b2_bab9_63a0_198a8131668f -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  c5706cd2_ff56_80ba_e35d_9c5a0c2b6647["attr()"]
  c5706cd2_ff56_80ba_e35d_9c5a0c2b6647 -->|calls| d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  style d6dfd043_7103_f2c7_aab3_9660fb0a5f75 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/escaping.js lines 9–26

export function escape_html(value, is_attr) {
	const str = String(value ?? '');

	const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
	pattern.lastIndex = 0;

	let escaped = '';
	let last = 0;

	while (pattern.test(str)) {
		const i = pattern.lastIndex - 1;
		const ch = str[i];
		escaped += str.substring(last, i) + (ch === '&' ? '&' : ch === '"' ? '"' : '<');
		last = i + 1;
	}

	return escaped + str.substring(last);
}

Subdomains

Frequently Asked Questions

What does escape_html() do?
escape_html() is a function in the svelte codebase, defined in packages/svelte/src/escaping.js.
Where is escape_html() defined?
escape_html() is defined in packages/svelte/src/escaping.js at line 9.
What calls escape_html()?
escape_html() is called by 9 function(s): attr, attr_class, attr_style, build_attribute_value, build_element_attributes, build_set_class, process_children, stringify, and 1 more.

Analyze Your Own Codebase

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

Try Supermodel Free