Skip to content

fix(model): handle boolean YAML scalars in component props and add Issue #75 tests#94

Merged
davideast merged 1 commit into
mainfrom
fix/harden-non-string-component-props
Jun 2, 2026
Merged

fix(model): handle boolean YAML scalars in component props and add Issue #75 tests#94
davideast merged 1 commit into
mainfrom
fix/harden-non-string-component-props

Conversation

@davideast
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to PR #79 (fix for Issue #75). Two changes:

1. Explicitly handle booleans in the component property loop

The component property loop in ModelHandler checked for typeof rawValue === 'number' but let booleans (visible: true, disabled: false) fall through to string-only helpers like isTokenReference and isValidColor. Those functions happened to not crash because:

This worked by accident, not by design. This change adds typeof rawValue === 'boolean' next to the number check so the intent is clear and booleans never enter the string parsing path.

2. Add tests for Issue #75

PR #79 fixed the crash but shipped without tests. This adds three test cases:

Testing

All 241 tests pass (including the 3 new ones).

…sue #75 tests

The component property loop only checked for typeof 'number' before
passing values to string-only helpers (isTokenReference, isValidColor,
isParseableDimension). Boolean YAML values (e.g. visible: true) fell
through to those helpers and only survived by accident due to the typeof
guards added in PR #79. This change handles booleans explicitly alongside
numbers so the intent is clear.

Adds three tests covering the exact reproducer from Issue #75
(opacity: 0.9), boolean properties (visible: true), and a mixed case
with numbers, booleans, and strings in the same component.
@davideast davideast merged commit 4f28dd2 into main Jun 2, 2026
13 checks passed
@davideast davideast deleted the fix/harden-non-string-component-props branch June 2, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant