1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

when document is very big ,toArray is very time-consuming (#2404)

* when document is very big  ,`toArray` is very time-consuming

* when document is very big  ,`toArray` is very time-consuming
This commit is contained in:
云无心
2018-11-10 00:28:11 +08:00
committed by Ian Storm Taylor
parent 6ddba0ea35
commit 65d662fea1

View File

@@ -361,7 +361,7 @@ function validateLast(node, rule) {
function validateNodes(node, rule, rules = []) { function validateNodes(node, rule, rules = []) {
if (node.nodes == null) return if (node.nodes == null) return
const children = node.nodes.toArray() const children = node.nodes
const defs = rule.nodes != null ? rule.nodes.slice() : [] const defs = rule.nodes != null ? rule.nodes.slice() : []
let count = 0 let count = 0
let lastCount = 0 let lastCount = 0
@@ -386,8 +386,8 @@ function validateNodes(node, rule, rules = []) {
function nextChild() { function nextChild() {
index += 1 index += 1
previous = child previous = child
child = children[index] child = children.get(index)
next = children[index + 1] next = children.get(index + 1)
if (!child) return false if (!child) return false
lastCount = count lastCount = count
count += 1 count += 1