Home / Function/ handleBooleanAttribute() — astro Function Reference

handleBooleanAttribute() — astro Function Reference

Architecture documentation for the handleBooleanAttribute() function in util.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  6a8bccff_747d_4ec9_706f_71a3b71d7341["handleBooleanAttribute()"]
  05241a8b_1820_8286_5770_4da18477ecde["util.ts"]
  6a8bccff_747d_4ec9_706f_71a3b71d7341 -->|defined in| 05241a8b_1820_8286_5770_4da18477ecde
  f16d0d52_160f_152d_f7fe_a1fd178b948b["addAttribute()"]
  f16d0d52_160f_152d_f7fe_a1fd178b948b -->|calls| 6a8bccff_747d_4ec9_706f_71a3b71d7341
  929650c8_51d4_a031_aec7_5c4070f1a602["isCustomElement()"]
  6a8bccff_747d_4ec9_706f_71a3b71d7341 -->|calls| 929650c8_51d4_a031_aec7_5c4070f1a602
  18707fa5_5c92_baf5_b50a_c1f739e143b2["toAttributeString()"]
  6a8bccff_747d_4ec9_706f_71a3b71d7341 -->|calls| 18707fa5_5c92_baf5_b50a_c1f739e143b2
  style 6a8bccff_747d_4ec9_706f_71a3b71d7341 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/runtime/server/render/util.ts lines 66–78

function handleBooleanAttribute(
	key: string,
	value: any,
	shouldEscape: boolean,
	tagName?: string,
): string {
	// For custom elements, always render as string attributes
	if (tagName && isCustomElement(tagName)) {
		return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
	}
	// For regular HTML elements, use boolean attribute logic
	return markHTMLString(value ? ` ${key}` : '');
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does handleBooleanAttribute() do?
handleBooleanAttribute() is a function in the astro codebase, defined in packages/astro/src/runtime/server/render/util.ts.
Where is handleBooleanAttribute() defined?
handleBooleanAttribute() is defined in packages/astro/src/runtime/server/render/util.ts at line 66.
What does handleBooleanAttribute() call?
handleBooleanAttribute() calls 2 function(s): isCustomElement, toAttributeString.
What calls handleBooleanAttribute()?
handleBooleanAttribute() is called by 1 function(s): addAttribute.

Analyze Your Own Codebase

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

Try Supermodel Free