mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-26 00:27:28 +02:00
Fixed nested object comparison when the second value doesn't have that key (#4518)
This commit is contained in:
5
.changeset/eleven-taxis-hear.md
Normal file
5
.changeset/eleven-taxis-hear.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed flaw in deep-equal algorithm when dealing with nested mark objects
|
@@ -17,7 +17,7 @@ export const isDeepEqual = (
|
|||||||
for (const key in node) {
|
for (const key in node) {
|
||||||
const a = node[key]
|
const a = node[key]
|
||||||
const b = another[key]
|
const b = another[key]
|
||||||
if (isPlainObject(a)) {
|
if (isPlainObject(a) && isPlainObject(b)) {
|
||||||
if (!isDeepEqual(a, b)) return false
|
if (!isDeepEqual(a, b)) return false
|
||||||
} else if (Array.isArray(a) && Array.isArray(b)) {
|
} else if (Array.isArray(a) && Array.isArray(b)) {
|
||||||
if (a.length !== b.length) return false
|
if (a.length !== b.length) return false
|
||||||
|
@@ -0,0 +1,21 @@
|
|||||||
|
import { isDeepEqual } from '../../../src/utils/deep-equal'
|
||||||
|
|
||||||
|
export const input = {
|
||||||
|
objectA: {
|
||||||
|
text: 'same text',
|
||||||
|
bold: true,
|
||||||
|
italic: { origin: 'inherited', value: true },
|
||||||
|
underline: { origin: 'inherited', value: false },
|
||||||
|
},
|
||||||
|
objectB: {
|
||||||
|
text: 'same text',
|
||||||
|
bold: true,
|
||||||
|
italic: { origin: 'inherited', value: true },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const test = ({ objectA, objectB }) => {
|
||||||
|
return isDeepEqual(objectA, objectB)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = false
|
Reference in New Issue
Block a user