{"version":3,"file":"elementMatchesRule.mjs","sources":["../../../src/parser/elementMatchesRule.ts"],"sourcesContent":["import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(\n  element: HTMLElement | SVGElement,\n  selectors: string[],\n) {\n  let parentMatching = true;\n  // start from rightmost selector.\n  const firstMatching = selectorMatches(element, selectors.pop()!);\n  if (firstMatching && selectors.length) {\n    parentMatching = doesSomeParentMatch(element, selectors);\n  }\n  return firstMatching && parentMatching && selectors.length === 0;\n}\n"],"names":["elementMatchesRule","element","selectors","parentMatching","firstMatching","selectorMatches","pop","length","doesSomeParentMatch"],"mappings":";;;AAGA;AACA;AACA;;AAEO,SAASA,kBAAkBA,CAChCC,OAAiC,EACjCC,SAAmB,EACnB;EACA,IAAIC,cAAc,GAAG,IAAI;AACzB;EACA,MAAMC,aAAa,GAAGC,eAAe,CAACJ,OAAO,EAAEC,SAAS,CAACI,GAAG,EAAG,CAAC;AAChE,EAAA,IAAIF,aAAa,IAAIF,SAAS,CAACK,MAAM,EAAE;AACrCJ,IAAAA,cAAc,GAAGK,mBAAmB,CAACP,OAAO,EAAEC,SAAS,CAAC;AAC1D,EAAA;EACA,OAAOE,aAAa,IAAID,cAAc,IAAID,SAAS,CAACK,MAAM,KAAK,CAAC;AAClE;;;;"}