isEqual returns true for objects with different keys when a value is undefined, and for {} vs []
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- react, typescript
- Bereich
- frontend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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/
- Vorherrschende Sprache
- TypeScript
- Sterne
- 671
- Forks
- 214
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react-component/util
-
isEqual: false 'circular references' warning for a reference repeated across sibling keysEvtl. vergeben @savkaoleg hat das vor 79 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
react-component/util#816 ·
-
injectCSS method not attaching csp nonce passed to it. it is used in antd components internallyOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
react-component/util#671 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
react-component/util#738 · 1 Kommentar · 1 Reaktion ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
react-component/util#710 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
react-component/util#647 · 5 Kommentare ·
Alle Issues in react-component/util
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Inbox: permission prompt (perm:) sessions appear as duplicate agents in the recipient picker and participantsEvtl. vergeben @Djiit hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
backnotprop/plannotator#4517 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
MoonshotAI/kimi-code#6000 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
OpenSlides/openslides-client#6768 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 90/100
modelcontextprotocol/modelcontextprotocol#3622 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag