isEqual returns true for objects with different keys when a value is undefined, and for {} vs []
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
The bug is in the object branch of src/isEqual.ts, which compares key counts and then recurses only over the keys of a. Read that branch first, and check how it handles array versus object inputs and keys missing from b. Pull request #830 is already open against this issue, so review it before starting new work. Done means the five calls in the repro script return false, and the existing isEqual tests still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
isEqual returns true for objects with different keys when one has an undefined value, and when comparing an object with an array.
// npm i @rc-component/[email protected]
const isEqual = require("@rc-component/util/lib/isEqual").default;
console.log(isEqual({ a: undefined }, { b: 1 })); // true
console.log(isEqual({ a: 1, b: undefined }, { a: 1, c: 2 })); // true
console.log(isEqual({}, [])); // true
console.log(isEqual({ 0: 1 }, [1])); // true
console.log(isEqual([1], { 0: 1 })); // false
Command: node repro.cjs
Actual output:
true
true
true
true
false
Expected output: false for all five calls.
In src/isEqual.ts, the object branch compares Object.keys(a).length !== Object.keys(b).length and then checks deepEqual(a[key], b[key]) only for the keys of a, without checking Array.isArray(b) or Object.prototype.hasOwnProperty.call(b, key).
Version: @rc-component/[email protected] and master (149b6c2585), tested on Node v26.13.0. (Separate from #816.)
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- TypeScript
- Star
- 671
- Fork
- 214
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react-component/util
-
isEqual: false 'circular references' warning for a reference repeated across sibling keysCó thể đã có người làm @savkaoleg đã nhận 79 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
react-component/util#816 ·
-
injectCSS method not attaching csp nonce passed to it. it is used in antd components internallyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
react-component/util#671 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/util#738 · 1 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
react-component/util#710 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
react-component/util#647 · 5 bình luận ·
Tất cả issue của react-component/util
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Inbox: permission prompt (perm:) sessions appear as duplicate agents in the recipient picker and participantsCó thể đã có người làm @Djiit đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
backnotprop/plannotator#4517 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
MoonshotAI/kimi-code#6000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
OpenSlides/openslides-client#6768 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
modelcontextprotocol/modelcontextprotocol#3622 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày