UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

1 lines 1.2 kB
{"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(element: HTMLElement, selectors: string[]) {\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,CAACC,OAAoB,EAAEC,SAAmB,EAAE;EAC5E,IAAIC,cAAc,GAAG,IAAI,CAAA;AACzB;EACA,MAAMC,aAAa,GAAGC,eAAe,CAACJ,OAAO,EAAEC,SAAS,CAACI,GAAG,EAAG,CAAC,CAAA;AAChE,EAAA,IAAIF,aAAa,IAAIF,SAAS,CAACK,MAAM,EAAE;AACrCJ,IAAAA,cAAc,GAAGK,mBAAmB,CAACP,OAAO,EAAEC,SAAS,CAAC,CAAA;AAC1D,GAAA;EACA,OAAOE,aAAa,IAAID,cAAc,IAAID,SAAS,CAACK,MAAM,KAAK,CAAC,CAAA;AAClE;;;;"}