Skip to content

cls=None renders as literal string 'None' in HTML class attribute #162

Description

@linguistic76

Summary

Passing cls=None to MonsterUI components results in the literal string "None" appearing in the rendered HTML class attribute, rather than the attribute being omitted.

Reproduction

from monsterui.franken import Card
print(to_xml(Card("content", cls=None)))
# Renders: <div class="None uk-card ...">content</div>
#                   ^^^^^ literal "None"

Expected behaviour

When cls=None is passed, the cls argument should be treated as absent — the same as not passing cls at all. The class attribute should contain only the component's default classes.

Current workaround

Every wrapper in downstream code must guard against None explicitly:

# Required in every wrapper to avoid "None" appearing in class output
MCardBody(*c, cls=cls, **kwargs) if cls else MCardBody(*c, **kwargs)

This boilerplate is needed on every component wrapper and is easy to forget.

Suggested fix

Guard against None in the class-building path so cls=None is equivalent to cls="" or omitting cls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions