1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 20:24:01 +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

@@ -0,0 +1,73 @@
/** @jsx h */
import assert from 'assert'
import h from '../..'
export const input = (
<document>
<block type="paragraph">
Cat <inline type="link">is</inline>
<text key="a"> cute</text>
</block>
</document>
)
export function test() {
const block = input.nodes.first()
assert.notEqual(block.nodes.first().key, 'a')
assert.equal(block.nodes.last().key, 'a')
}
export const output = {
object: 'document',
data: {},
nodes: [
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
object: 'text',
leaves: [
{
object: 'leaf',
text: 'Cat ',
marks: [],
},
],
},
{
object: 'inline',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
object: 'text',
leaves: [
{
object: 'leaf',
text: 'is',
marks: [],
},
],
},
],
},
{
object: 'text',
leaves: [
{
object: 'leaf',
text: ' cute',
marks: [],
},
],
},
],
},
],
}

View File

@@ -27,6 +27,7 @@ describe('slate-hyperscript', () => {
const actual = input.toJSON()
const expected = Value.isValue(output) ? output.toJSON() : output
assert.deepEqual(actual, expected)
if (module.test) module.test()
})
}
})