isEqual returns true for objects with different keys when a value is undefined, and for {} vs []
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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/
- Lingua principale
- TypeScript
- Stelle
- 671
- Fork
- 214
- Merge medio
- 2g 1h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di react-component/util
-
isEqual: false 'circular references' warning for a reference repeated across sibling keysForse già presa @savkaoleg l’ha presa 79 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
react-component/util#816 ·
-
injectCSS method not attaching csp nonce passed to it. it is used in antd components internallyAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
react-component/util#671 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
react-component/util#738 · 1 commento · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
react-component/util#710 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
react-component/util#647 · 5 commenti ·
Tutte le issue di react-component/util
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Inbox: permission prompt (perm:) sessions appear as duplicate agents in the recipient picker and participantsForse già presa @Djiit l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
backnotprop/plannotator#4517 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
MoonshotAI/kimi-code#6000 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
OpenSlides/openslides-client#6768 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 90/100
modelcontextprotocol/modelcontextprotocol#3622 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno