import ContextMapper from "./ContextMapper";
import Rule from "./Rule";

export default class XPathContextMapper extends ContextMapper {
    constructor(context : string) {
        super(context);
    }

    buildElementToRuleMap() : Map<Element, Rule[]> {
        let xpathQueryResult = document.evaluate(this._context, document, null, XPathResult.ANY_TYPE, null);
        let context = xpathQueryResult.iterateNext();
        if (context instanceof Element) {
            return this.buildElementToRuleMapForSelectors(context);
        } else {
            return new Map();
        }
    }
    
}