import { querySelectorAllDeep } from 'query-selector-shadow-dom';
import ActionStrategy from './ActionStrategy';
import Action from '../../Action';
import Rule from '../Rule';

export default class ValueStrategy implements ActionStrategy {

    static makeAction(rule, event, listenedElement): Action {
        return new Action(rule.prefix, event.target.value);
    }

    static actionToElements(rule: Rule, action: Action): Element[] {
        if (action.prefix !== rule.prefix) {
            return [];
        }
        return querySelectorAllDeep(rule.selector)
    }
}
