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


export default class SimpleStrategy implements ActionStrategy {

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

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