1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

Checks for nodes in isLeafBlock & isLeafInline (#2357)

These functions now check for `nodes` before running `nodes.first()`
This commit is contained in:
Slapbox 2018-10-31 17:15:38 -04:00 committed by Ian Storm Taylor
parent 317297469e
commit a8c08581a5

View File

@ -1428,6 +1428,7 @@ class ElementInterface {
isLeafBlock() { isLeafBlock() {
const { object, nodes } = this const { object, nodes } = this
if (!nodes.size) return true
const first = nodes.first() const first = nodes.first()
return object === 'block' && first.object !== 'block' return object === 'block' && first.object !== 'block'
} }
@ -1440,6 +1441,7 @@ class ElementInterface {
isLeafInline() { isLeafInline() {
const { object, nodes } = this const { object, nodes } = this
if (!nodes.size) return true
const first = nodes.first() const first = nodes.first()
return object === 'inline' && first.object !== 'inline' return object === 'inline' && first.object !== 'inline'
} }