typst/typst · error

custom element name must not contain uppercase letters

Error message

custom element name must not contain uppercase letters

What it means

Guard in HtmlAttr::intern/element interning: when a candidate custom element name (one containing a hyphen) contains an ASCII uppercase letter, it is rejected because the WHATWG custom-elements spec only permits lowercase names; such a name would create an invalid custom element.

Source

Thrown at crates/typst-html/src/dom.rs:289

        }

        // If we encounter a hyphen, we are dealing with a custom element rather
        // than a standard HTML element.
        //
        // A valid custom element name must:
        // - Contain at least one hyphen (U+002D)
        // - Start with an ASCII lowercase letter (a-z)
        // - Not contain any ASCII uppercase letters (A-Z)
        // - Not be one of the reserved names
        // - Only contain valid characters (ASCII alphanumeric and hyphens)
        //
        // See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
        if has_hyphen {
            if !string.starts_with(|c: char| c.is_ascii_lowercase()) {
                bail!("custom element name must start with a lowercase letter");
            }
            if has_uppercase {
                bail!("custom element name must not contain uppercase letters");
            }

            // These names are used in SVG and MathML. Since `html.elem` only
            // supports creation of _HTML_ elements, they are forbidden.
            if matches!(
                string,
                "annotation-xml"
                    | "color-profile"
                    | "font-face"
                    | "font-face-src"
                    | "font-face-uri"
                    | "font-face-format"
                    | "font-face-name"
                    | "missing-glyph"
            ) {
                bail!("name is reserved and not valid for a custom element");
            }
        }

View on GitHub (pinned to 35417aa769)

Solutions

  1. Rewrite the element name using only lowercase letters, digits, and hyphens (e.g. "my-widget" instead of "myWidget")
  2. If camelCase is desired, convert to kebab-case before passing the name to html.elem
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/typst-html/src/dom.rs:289 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of typst/typst@35417aa769 (2026-08-17). Data as JSON: /api/errors/e1a1dfb979d656d2. Report an issue: GitHub.