Skip to content

Commit

Permalink
Fix deep-equality for array properties (#4672)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorBaron committed Nov 22, 2021
1 parent 0540fea commit 2523dc4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .changeset/merge-nodes-issue

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/wicked-mayflies-approve.md
@@ -0,0 +1,5 @@
---
'slate': minor
---

Fix - deep-equals was always returning true when array props were equals.
1 change: 0 additions & 1 deletion packages/slate/src/utils/deep-equal.ts
Expand Up @@ -24,7 +24,6 @@ export const isDeepEqual = (
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false
}
return true
} else if (a !== b) {
return false
}
Expand Down
20 changes: 20 additions & 0 deletions packages/slate/test/utils/deep-equal/deep-equals-with-array.js
@@ -0,0 +1,20 @@
import { isDeepEqual } from '../../../src/utils/deep-equal'

export const input = {
objectA: {
text: 'same text',
array: ['array-content'],
bold: true,
},
objectB: {
text: 'same text',
array: ['array-content'],
bold: true,
},
}

export const test = ({ objectA, objectB }) => {
return isDeepEqual(objectA, objectB)
}

export const output = true
20 changes: 20 additions & 0 deletions packages/slate/test/utils/deep-equal/deep-not-equals-with-array.js
@@ -0,0 +1,20 @@
import { isDeepEqual } from '../../../src/utils/deep-equal'

export const input = {
objectA: {
text: 'same text',
array: ['array-content'],
bold: true,
},
objectB: {
text: 'same text',
array: ['array-content'],
bold: false,
},
}

export const test = ({ objectA, objectB }) => {
return isDeepEqual(objectA, objectB)
}

export const output = false

0 comments on commit 2523dc4

Please sign in to comment.