mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-13 10:44:02 +02:00
Deduplicate dirty paths for normalization. (#2916)
* Deduplicate dirty paths for normalization. * Update editor.js
This commit is contained in:
committed by
Ian Storm Taylor
parent
8ab49c04c4
commit
ff831eba7d
@@ -107,7 +107,20 @@ class Editor {
|
||||
return transformed.toArray()
|
||||
})
|
||||
|
||||
this.tmp.dirty = Array.prototype.concat.apply(newDirtyPaths, dirty)
|
||||
const pathIndex = {}
|
||||
const dirtyPaths = Array.prototype.concat.apply(newDirtyPaths, dirty)
|
||||
this.tmp.dirty = []
|
||||
|
||||
// PERF: De-dupe the paths so we don't do extra normalization.
|
||||
dirtyPaths.forEach(dirtyPath => {
|
||||
const key = dirtyPath.join(',')
|
||||
|
||||
if (!pathIndex[key]) {
|
||||
this.tmp.dirty.push(dirtyPath)
|
||||
}
|
||||
|
||||
pathIndex[key] = true
|
||||
})
|
||||
|
||||
// If we're not already, queue the flushing process on the next tick.
|
||||
if (!this.tmp.flushing) {
|
||||
|
Reference in New Issue
Block a user