Props reference

Purpose

Props is the deterministic attribute map for Element nodes.

Inputs

Entry Required Type Behavior
<name> no scalar attribute value Keys are sorted before rendering. Values may be string, number, boolean, or null. Strings and numbers are escaped as attribute text, regular true renders the string value "true", false and null omit the attribute, and empty string renders an empty attribute value. Use bool:<name> for HTML boolean attributes that should render without a value.
bool:<name> no boolean attribute entry Boolean attribute syntax for flags such as bool:disabled: true. True renders <name> without a value, false or omitted leaves it out.

Boundary

Attribute ordering is stable across renders. Attribute names must be valid HTML attribute names. Regular attributes are limited to id, class, title, role, data-*, and aria-*. Direct Props validation rejects event handler attributes such as onclick, uppercase or malformed names, and raw style. URL-bearing attributes such as href or src fail validation in v0.1.1. Numeric values must be finite.

Go Shape

import "github.com/busdk/bus-gx/pkg/gx"

props := gx.Props{
	"class":         "bus-button",
	"bool:disabled": false,
}

The rendered attribute string is:

class="bus-button"