epiphany/node_modules/css-has-pseudo/dist/browser.cjs.map

1 line
44 KiB
Text
Raw Normal View History

2023-12-09 22:48:07 -08:00
{"version":3,"file":"browser.cjs","sources":["../src/encode/decode.mjs","../src/encode/extract.mjs","../src/encode/encode.mjs","../src/browser.js","../../../node_modules/@mrhenry/core-web/modules/~element-qsa-has.js"],"sourcesContent":["\n/** Decodes an identifier back into a CSS selector */\nexport default function decodeCSS(value) {\n\tif (value.slice(0, 13) !== 'csstools-has-') {\n\t\treturn '';\n\t}\n\n\tvalue = value.slice(13);\n\tlet values = value.split('-');\n\n\tlet result = '';\n\tfor (let i = 0; i < values.length; i++) {\n\t\tresult += String.fromCharCode(parseInt(values[i], 36));\n\t}\n\n\treturn result;\n}\n","import decodeCSS from './decode.mjs';\n\n/** Extract encoded selectors out of attribute selectors */\nexport default function extractEncodedSelectors(value) {\n\tlet out = [];\n\n\tlet depth = 0;\n\tlet candidate;\n\n\tlet quoted = false;\n\tlet quotedMark;\n\n\tlet containsUnescapedUnquotedHasAtDepth1 = false;\n\n\t// Stryker disable next-line EqualityOperator\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst char = value[i];\n\n\t\tswitch (char) {\n\t\t\tcase '[':\n\t\t\t\tif (quoted) {\n\t\t\t\t\tcandidate += char;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (depth === 0) {\n\t\t\t\t\tcandidate = '';\n\t\t\t\t} else {\n\t\t\t\t\tcandidate += char;\n\t\t\t\t}\n\n\t\t\t\tdepth++;\n\t\t\t\tcontinue;\n\t\t\tcase ']':\n\t\t\t\tif (quoted) {\n\t\t\t\t\tcandidate += char;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t{\n\t\t\t\t\tdepth--;\n\t\t\t\t\tif (depth === 0) {\n\t\t\t\t\t\tconst decoded = decodeCSS(candidate);\n\t\t\t\t\t\tif (containsUnescapedUnquotedHasAtDepth1) {\n\t\t\t\t\t\t\tout.push(decoded);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcandidate += char;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcontinue;\n\t\t\tcase '\\\\':\n\t\t\t\tcandidate += value[i];\n\t\t\t\tcandidate += value[i+1];\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\n\t\t\tcase '\"':\n\t\t\tcase '\\'':\n\t\t\t\tif (quoted && char === quotedMark) {\n\t\t\t\t\tquoted = false;\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (quoted) {\n\t\t\t\t\tcandidate += char;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tquoted = true;\n\t\t\t\tquotedMark = char;\n\t\t\t\tcontinue;\n\n\t\t\tdefault:\n\t\t\t\tif (candidate === '' && depth === 1 && (value.slice(i, i + 13) === 'csstools-has-')) {\n\t\t\t\t\tcontainsUnescapedUnquotedHasAtDepth1 = true;\n\t\t\t\t}\n\n\t\t\t\tcandidate += char;\n\t\t\t\tcontinue;\n\t\t}\n\t}\n\n\tconst unique = [];\n\tfor (let i = 0; i < out.length; i++) {\n\t\tif (unique.indexOf(out[i]) === -1) {\n\t\t\tunique.push(out[i]);\n\t\t}\n\t}\n\n\treturn unique;\n}\n","\n/** Returns the string as an encoded CSS identifier. */\nexport default function encodeCSS(value) {\n\tif (value === '') {\n\t\treturn '';\n\t}\n\n\tlet hex;\n\tlet result = '';\n\tfor (let i = 0; i < value.length; i++) {\n\t\thex = value.charCodeAt(i).toString(36);\n\t\tif (i === 0) {\n\t\t\tresult += hex;\n\t\t} else {\n\t\t\tresult += '-' + hex;\n\t\t}\n\t}\n\n\treturn 'csstools-has-' + result;\n}\n","/* global MutationObserver,requestAnimationFrame,cancelAnimationFrame,self,HTMLElement */\n\nimport '@mrhenry/core-web/modules/~element-qsa-has.js';\nimport extractEncodedSelectors from './encode/extract.mjs';\nimport encodeCSS from './encode/encode.mjs';\n\nfunction hasNativeSupport() {\n\ttry {\n\t\tif (!('CSS' in self) || !('supports' in self.CSS) || !self.CSS.supports('selector(:has(div))')) {\n\t\t\treturn false;\n\t\t}\n\n\t} catch (_) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nexport default function cssHasPseudo(document, options) {\n\t// OPTIONS\n\t{\n\t\tif (!options) {\n\t\t\toptions = {};\n\t\t}\n\n\t\toptions = {\n\t\t\thover: (!!options.hover) || false,\n\t\t\tdebug: (!!options.debug) || false,\n\t\t\tobservedAttributes: options.observedAttributes || [],\n\t\t\tforcePolyfill: (!!options.forcePolyfill) || false,\n\t\t};\n\n\t\toptions.mustPolyfill = options.forcePolyfill || !hasNativeSupport();\n\n\t\tif (!Array.isArray(options.observedAttributes)) {\n\t\t\toptions.observedAttributes = [];\n\t\t}\n\n\t\toptions.observedAttributes = options.observedA