mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-06 07:17:27 +02:00
Fix a hyperscript bug in perserving text-key (#1846)
* Perserve the text key in the right way * rename assertation to test
This commit is contained in:
committed by
Ian Storm Taylor
parent
dd3e9effff
commit
727a7ece26
@@ -264,7 +264,8 @@ function createChildren(children, options = {}) {
|
||||
let length = 0
|
||||
|
||||
// When creating the new node, try to preserve a key if one exists.
|
||||
const firstText = children.find(c => Text.isText(c))
|
||||
const firstNodeOrText = children.find(c => typeof c !== 'string')
|
||||
const firstText = Text.isText(firstNodeOrText) ? firstNodeOrText : null
|
||||
const key = options.key ? options.key : firstText ? firstText.key : undefined
|
||||
let node = Text.create({ key })
|
||||
|
||||
|
Reference in New Issue
Block a user