isEqual returns true for objects with different keys when a value is undefined, and for {} vs []
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react, typescript
- 領域
- frontend
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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/
- 主要語言
- TypeScript
- 星號
- 671
- 分支
- 214
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
react-component/util 的其他 Issue
-
isEqual: false 'circular references' warning for a reference repeated across sibling keys可能已有人在做 @savkaoleg 於 79 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
react-component/util#816 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
react-component/util#671 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
react-component/util#738 · 1 則留言 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 25/100
react-component/util#710 ·
-
難度 3/5 1-2 天 新手友好度 25/100
react-component/util#647 · 5 則留言 ·
查看 react-component/util 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
Inbox: permission prompt (perm:) sessions appear as duplicate agents in the recipient picker and participants可能已有人在做 @Djiit 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
backnotprop/plannotator#4517 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
MoonshotAI/kimi-code#6000 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 65/100
OpenSlides/openslides-client#6768 ·
維護者通常 1 天內回覆
-
bug
難度 1/5 1-3 小時 新手友好度 90/100
modelcontextprotocol/modelcontextprotocol#3622 · 1 則留言 ·
維護者通常 1 天內回覆