Handle default transform values when strings#3487
Conversation
When passing scale: "0" or similar string values, the buildTransform function was incorrectly treating these as default values because it only checked if parseFloat(value) === 0 for string values. For scale properties, the default is 1, not 0. This fix makes the string branch mirror the number branch logic, checking against 1 for scale properties and 0 for others. Fixes #3465
Code ReviewSummary: This PR correctly fixes a bug where string scale values of "0" were being incorrectly treated as default values and omitted from the generated transform string. The fix is well-implemented and includes appropriate test coverage. ✅ Strengths
🐛 Critical Issue FoundThere's a duplicate bug in another file that also needs fixing:
} else {
valueIsDefault = parseFloat(value) === 0 // ❌ Wrong for scale properties
}This should be: } else {
const parsed = parseFloat(value)
valueIsDefault = key.startsWith("scale") ? parsed === 1 : parsed === 0
}This file appears to be a different implementation of 📝 Minor Suggestions
🔒 Security & Performance
✅ Code Style
Recommended ActionPlease fix the duplicate bug in Files to update:
Once that's addressed, this will be ready to merge! 🚀 |
Apply the same fix to the duplicate buildTransform function in effects/style/transform.ts. This ensures string scale values of "0" are correctly handled in the styleEffect code path as well. Fixes #3465
Pull Request ReviewSummaryThis PR fixes a bug where string values of Code Quality & Best Practices ✅Strengths:
Suggestions: None - the code follows the repository's style conventions and is clear and maintainable. Correctness & Potential Issues ✅Analysis:
Edge Cases Covered:
No Issues Found - the logic is sound and handles all relevant cases. Performance Considerations ✅Impact:
Assessment: No performance concerns. Security Concerns ✅Analysis:
Assessment: No security concerns. Test Coverage ✅Coverage Analysis:
Minor Suggestion: Consider adding a test case for "0%" to ensure percentage strings are also handled correctly. However, the current test coverage is sufficient. Additional ObservationsBug Fix Verification:
Code Consistency:
RecommendationApprove and Merge ✅ This is a clean, well-tested bug fix that:
The implementation is correct and ready to merge. |
When passing scale: "0" or similar string values, the buildTransform function was incorrectly treating these as default values because it only checked if parseFloat(value) === 0 for string values.
For scale properties, the default is 1, not 0. This fix makes the string branch mirror the number branch logic, checking against 1 for scale properties and 0 for others.
Fixes #3465