/** * guy */ import { Behavior } from "./0.behavior"; import { isFunction, each } from "../2.base"; import { Single } from "../../base"; export class HighlightBehavior extends Behavior { doBehavior(items) { const args = Array.prototype.slice.call(arguments, 1), { rule } = this.options; each(items, (i, item) => { if (item instanceof Single) { const rules = rule(item.getValue(), item); function doBe (run) { if (run === true) { item.doHighLight && item.doHighLight(...args); } else { item.unHighLight && item.unHighLight(...args); } } if (isFunction(rules)) { rules(doBe); } else { doBe(rules); } } else { item.doBehavior && item.doBehavior(...args); } }); } }