-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle null or undefined elements
#3478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Review: Handle null or undefined elementsSummaryThis PR successfully addresses issue #3390 by restoring Motion 10's permissive behavior for null/undefined elements in animation sequences. The changes are well-structured and appropriately handle edge cases. Strengths
Code Quality Observations
Minor Considerations
Security & PerformanceNo security concerns. The changes are purely about graceful degradation when elements don't exist. The filtering operations are efficient and appropriate. Best Practices Alignment
Recommendations
ConclusionThis PR is ready to merge. The implementation is clean, type-safe, well-tested, and successfully restores the expected permissive behavior. The graceful handling approach (returning empty arrays instead of throwing) is superior to the previous invariant checks. Great work on the comprehensive test coverage! |
Previously, passing null elements to animateSequence (e.g., from querySelector returning null) would throw an error. This was a regression from Motion 10's permissive behavior. Changes: - Update resolveElements in motion-dom to return empty array for null/undefined input and filter null elements from arrays - Update resolveSubjects in framer-motion to handle null/undefined subjects gracefully - Add early return for null/undefined in animateSubject and animateElements to gracefully skip (distinct from throwing for selectors that match no elements) - Add tests for null element handling in sequences Fixes #3390
2203f9a to
6ccb2ed
Compare
Pull Request ReviewSummaryThis PR successfully addresses issue #3390 by restoring Motion 10's permissive behavior for null/undefined elements in animation sequences. The changes are well-implemented and include comprehensive test coverage. Positive Aspects✅ Clear Problem Definition: The PR directly addresses a regression from Motion 10 where null elements (e.g., from ✅ Comprehensive Coverage: Changes span the entire call stack from low-level ✅ Good Test Coverage: Three new test cases cover the main scenarios:
✅ Type Safety: Properly extends type signatures to include ✅ Consistent Pattern: Uses the same null-check pattern ( Issues & Concerns🔴 Critical: Inconsistent Behavior in
|
Previously, passing null elements to animateSequence (e.g., from querySelector returning null) would throw an error. This was a regression from Motion 10's permissive behavior.
Changes:
Fixes #3390