Skip to content

Commit

Permalink
Switch to map + Array.prototype.concat.apply to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
brendancarney committed Feb 21, 2019
1 parent f5a7d9e commit 6a20d3b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/slate/src/controllers/editor.js
Expand Up @@ -100,14 +100,12 @@ class Editor {

// Get the paths of the affected nodes, and mark them as dirty.
const newDirtyPaths = getDirtyPaths(operation)
const dirty = this.tmp.dirty.reduce((memo, path) => {
path = PathUtils.create(path)
const transformed = PathUtils.transform(path, operation)
Array.prototype.push.apply(memo, transformed.toArray())
return memo
}, newDirtyPaths)

this.tmp.dirty = dirty

const dirty = this.tmp.dirty.map(path =>
PathUtils.transform(PathUtils.create(path), operation).toArray()
)

this.tmp.dirty = Array.prototype.concat.apply(newDirtyPaths, dirty)

// If we're not already, queue the flushing process on the next tick.
if (!this.tmp.flushing) {
Expand Down

0 comments on commit 6a20d3b

Please sign in to comment.