Skip to content

Theme attribute handling: empty string should remove attribute instead of setting it to empty #128

@coderabbitai

Description

@coderabbitai

Description

The applyThemeAttribute method in TabbedDemo.java currently calls setAttribute('theme', '') when the theme parameter is an empty string. According to Vaadin theming semantics, an empty string attribute is not the same as the attribute being absent — Flow distinguishes "attribute not set" (getAttribute() → null) from "attribute set but no tokens" (getThemeName() → empty string).

Current Behavior

When the theme is toggled off (dark mode unchecked), the code sets:

document.documentElement.setAttribute('theme', '')

This leaves an empty theme attribute on the document element.

Expected Behavior

When the theme parameter is empty, the attribute should be removed entirely:

document.documentElement.removeAttribute('theme')

Suggested Fix

Update applyThemeAttribute to check if the theme is empty and call removeAttribute('theme') instead of setAttribute('theme', '').

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Inbox (needs triage)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions