Remove assignment within if

This commit is contained in:
Josh Johnson 2017-08-14 13:33:20 +01:00
parent bfef79d3ee
commit e16ddb404f

View file

@ -1,6 +1,6 @@
import Fuse from 'fuse.js'; import Fuse from 'fuse.js';
import classNames from 'classnames'; import classNames from 'classnames';
import Store from './store/index.js'; import Store from './store/index';
import { import {
addItem, addItem,
removeItem, removeItem,
@ -1875,16 +1875,19 @@ class Choices {
} }
if (this.containerOuter.contains(target) && target !== this.input) { if (this.containerOuter.contains(target) && target !== this.input) {
let foundTarget;
const activeItems = this.store.getItemsFilteredByActive(); const activeItems = this.store.getItemsFilteredByActive();
const hasShiftKey = e.shiftKey; const hasShiftKey = e.shiftKey;
if (foundTarget = findAncestorByAttrName(target, 'data-button')) { const buttonTarget = findAncestorByAttrName(target, 'data-button');
this._handleButtonAction(activeItems, foundTarget); const itemTarget = findAncestorByAttrName(target, 'data-item');
} else if (foundTarget = findAncestorByAttrName(target, 'data-item')) { const choiceTarget = findAncestorByAttrName(target, 'data-choice');
this._handleItemAction(activeItems, foundTarget, hasShiftKey);
} else if (foundTarget = findAncestorByAttrName(target, 'data-choice')) { if (buttonTarget) {
this._handleChoiceAction(activeItems, foundTarget); this._handleButtonAction(activeItems, buttonTarget);
} else if (itemTarget) {
this._handleItemAction(activeItems, itemTarget, hasShiftKey);
} else if (choiceTarget) {
this._handleChoiceAction(activeItems, choiceTarget);
} }
e.preventDefault(); e.preventDefault();