AnswerDotAI / AnswerDotAI/MonsterUI
cls=None renders as literal string 'None' in HTML class attribute
- Dominant language
- Jupyter Notebook
- Stars
- 522
- Forks
- 33
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## 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
```python
from monsterui.franken import Card
print(to_xml(Card("content", cls=None)))
# Renders:
# ^^^^^ 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:
```python
# 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`.
Contributor guide
Research direction
Start with the monsterui.franken.Card entry point and reproduce the issue using to_xml(Card("content", cls=None)). Trace the class-building path to find where None becomes a string; done means cls=None omits "None" and leaves the component's default classes, matching the behavior of an omitted cls argument.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100