fix: switch observation when getter target changes - #243
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. Walkthrough本次变更重构 ChangesResizeObserver 目标切换
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The hook now switches observation from an old DOM element to its replacement without re-observing unchanged targets, with cleanup preserved. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Problem
A stable target getter can resolve to a different element after a render. The current effect depends on the getter identity, so an element A to element B change leaves the listener attached to A and never observes B.
Testing
npm test -- tests/useResizeObserver.spec.tsx --runInBand(2 passed)npm test -- --runInBand(4 suites, 21 tests passed)npm run tscnpm run compile(ESM, CJS, and declarations)npm run lint(0 errors; 2 pre-existing unused-disable warnings in observerUtil.ts)git diff --checkAI assistance disclosure: Codex was used to trace the lifecycle bug, implement the fix, run the exact-base regression proof and validation, audit open PR overlap, and draft this PR. All behavior and test results above were verified locally.
Summary by CodeRabbit
Bug Fixes
Tests