1
0
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:
Jinxuan Zhu
2018-06-10 19:34:06 -04:00
committed by Ian Storm Taylor
parent dd3e9effff
commit 727a7ece26
3 changed files with 76 additions and 1 deletions

View File

@@ -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 })