Skip to content

Commit

Permalink
Replace Array.find with detect utility function 🦈
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeJab committed Sep 20, 2019
1 parent 95146e0 commit ea54c6b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/js/editor/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Position from '../utils/cursor/position';
import Range from 'mobiledoc-kit/utils/cursor/range';
import { forEach, reduce, filter, values, commonItems } from '../utils/array-utils';
import { detect, forEach, reduce, filter, values, commonItems } from '../utils/array-utils';
import { DIRECTION } from '../utils/key';
import LifecycleCallbacks from '../models/lifecycle-callbacks';
import assert from '../utils/assert';
Expand Down Expand Up @@ -814,12 +814,12 @@ class PostEditor {

_determineNextRangeAfterToggleSection(range, sectionTransformations) {
if (sectionTransformations.length) {
let changedHeadSection = sectionTransformations
.find(({ from }) => { return from === range.headSection; })
.to;
let changedTailSection = sectionTransformations
.find(({ from }) => { return from === range.tailSection; })
.to;
let changedHeadSection = detect(sectionTransformations, ({ from }) => {
return from === range.headSection;
}).to;
let changedTailSection = detect(sectionTransformations, ({ from }) => {
return from === range.tailSection;
}).to;

if (changedHeadSection.isListSection || changedTailSection.isListSection) {
// We don't know to which ListItem's the original sections point at, so
Expand Down

0 comments on commit ea54c6b

Please sign in to comment.