{"name":"@csstools/postcss-is-pseudo-class","description":"A pseudo-class for matching elements in a selector list","version":"3.2.0","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","funding":{"type":"opencollective","url":"https://opencollective.com/csstools"},"engines":{"node":"^14 || ^16 || >=18"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs","default":"./dist/index.mjs"}},"dependencies":{"@csstools/selector-specificity":"^2.0.0","postcss-selector-parser":"^6.0.10"},"peerDependencies":{"postcss":"^8.4"},"devDependencies":{"@csstools/postcss-tape":"*","puppeteer":"^19.5.2"},"scripts":{"build":"rollup -c ../../rollup/default.mjs","docs":"node ../../.github/bin/generate-docs/install.mjs","lint":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run build && npm run test","test":"node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs","test:browser":"node ./test/_browser.mjs","test:rewrite-expects":"REWRITE_EXPECTS=true node .tape.mjs"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class#readme","repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"plugins/postcss-is-pseudo-class"},"bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"keywords":["css","is","matches","polyfill","postcss","postcss-plugin","pseudo","selector"],"csstools":{"exportName":"postcssIsPseudoClass","humanReadableName":"PostCSS Is Pseudo"},"volta":{"extends":"../../package.json"},"gitHead":"b8e5d16ba72b939264d031ac9154b683fd2f1e84","_id":"@csstools/postcss-is-pseudo-class@3.2.0","_nodeVersion":"18.13.0","_npmVersion":"9.4.1","dist":{"integrity":"sha512-uooelBL99jMg8ZD6xy0Pj1hSalchWmplcin00eI+JHpv1jW2iwbi1cn2UnVsToM4JLwJSZFzTSWCgSpmlyhe3A==","shasum":"1277cc187bdb075013341dab42b4140d1cafae27","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-is-pseudo-class/download/@csstools/postcss-is-pseudo-class-3.2.0.tgz","fileCount":14,"unpackedSize":35197,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEelh7/fT9LWGilpUgzl1NV2gdKcqrS3M1MvEKpY+Pf2AiEApx5R902eGj6GkWJaT74BjHjtnEwpBFhvF6zlp88HBLQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkM79DACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqTMQ/+MyQII9/7LyHlhzUr9YC6t+TMV+Y5aCMY0SVe76ADqHiVufWl\r\n20baOPjzH0NOk34A9NIiJp+gNX528iLWSjaT2ML+peVi/SHY8zhxdOCTkDyp\r\nLcZ6lGf0gL/Yr4EMmsnnNXCFvymS3bU3+VSn9E9+pAa3FOsrpCvCIJT0sWmC\r\nky+u756xcNfxAGhT3WPIkXAHZI6LzZ4NpGwLBrL5qiyfULgRvVVfKKY4f0Yg\r\nkAhV8w1iS1hO10/IuWF6pKYrJ9Yoo8tqTApXIV7g64WG7TS9pFBIR1lLnQNX\r\nA74YRlJUuTdsNCcUMcA+n91b2PQoQGOnCbzGRaxDk2LUH2HqgeBnYW/kmWL+\r\nOLWXgRftygehvD8Hvq32Zw4sY4BOr4E1b0D6AKCGG0JUyHaEUfEJVf78KGU2\r\naFNevEeRnynhM6RuKS6PKdOr+bxjP9U2YIQtk0cLULQQvKub1QoMvf84zaNX\r\nDHh6F1tWxtsrkVKPTTdhzKsybABstre4JkycYxPwzLrhuGH6B/zmwtfWaWST\r\ncSHRWDHFuIR+JJz8qvm+VOeiz0M6iSx4DIUFZJ/pFXsb6/0qf/btkh4R4/PL\r\nTyQ6ATgv8HnRCc7iDgD5iXRwtZVstP5R8RJny1/pTRzCIS1ddZ2MnezwHJ4/\r\nRZpj4T3CN13HVtQ6bHOmtzoGXmLsiFqsk94=\r\n=RwQz\r\n-----END PGP SIGNATURE-----\r\n","size":9756,"noattachment":false,"key":"/@csstools/postcss-is-pseudo-class/-/@csstools/postcss-is-pseudo-class-3.2.0.tgz"},"_npmUser":{"name":"alaguna","email":"sombragriselros@gmail.com"},"directories":{},"maintainers":[{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-is-pseudo-class_3.2.0_1681112899762_0.750335575821867"},"_hasShrinkwrap":false,"readme":"# PostCSS Is Pseudo [<img src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS\" width=\"90\" height=\"90\" align=\"right\">][postcss]\n\n[![NPM Version][npm-img]][npm-url]\n[<img alt=\"Build Status\" src=\"https://github.com/csstools/postcss-plugins/workflows/test/badge.svg\" height=\"20\">][cli-url]\n[<img alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white\">][discord]\n<br><br>\n[<img alt=\"Baseline Status\" src=\"https://cssdb.org/images/badges-baseline/is-pseudo-class.svg\" height=\"20\">][css-url]\n[![CSS Standard Status][css-img]][css-url]\n\n[PostCSS Is Pseudo Class] lets you use the `:is` pseudo class function, following the\n[CSS Selector] specification.\n\n```pcss\n:is(input, button):is(:hover, :focus) {\n\torder: 1;\n}\n```\n\nBecomes :\n\n```pcss\ninput:hover {\n\torder: 1;\n}\ninput:focus {\n\torder: 1;\n}\nbutton:hover {\n\torder: 1;\n}\nbutton:focus {\n\torder: 1;\n}\n```\n\n## Usage\n\nAdd [PostCSS Is Pseudo Class] to your project:\n\n```bash\nnpm install @csstools/postcss-is-pseudo-class --save-dev\n```\n\nUse [PostCSS Is Pseudo Class] as a [PostCSS] plugin:\n\n```js\nimport postcss from 'postcss';\nimport postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';\n\npostcss([\n  postcssIsPseudoClass(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS Is Pseudo Class] runs in all Node environments, with special instructions for:\n\n| [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |\n| --- | --- | --- | --- |\n\n## Options\n\n### preserve\n\nThe `preserve` option determines whether the original notation\nis preserved. By default, it is not preserved.\n\n```js\npostcss([\n  postcssIsPseudoClass({ preserve: true })\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n```pcss\n:is(input, button):is(:hover, :focus) {\n\torder: 1;\n}\n```\n\nBecomes :\n\n```pcss\ninput:hover {\n\torder: 1;\n}\ninput:focus {\n\torder: 1;\n}\nbutton:hover {\n\torder: 1;\n}\nbutton:focus {\n\torder: 1;\n}\n:is(input, button):is(:hover, :focus) {\n\torder: 1;\n}\n```\n\n### specificityMatchingName\n\nThe `specificityMatchingName` option allows you to change the selector used to adjust specificity.\nThe default value is `does-not-exist`.\nIf this is an actual class, id or tag name in your code, you will need to set a different option here.\n\nSee how `:not` is used to modify [specificity](#specificity).\n\n```js\npostcss([\n  postcssIsPseudoClass({ specificityMatchingName: 'something-random' })\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n```pcss\n:is(.button, button):hover {\n\torder: 7;\n}\n```\n\nBecomes :\n\n```pcss\n.button:hover {\n\torder: 7;\n}\n\nbutton:not(.something-random):hover {\n\torder: 7;\n}\n```\n\n### onComplexSelector\n\nWarn on complex selectors in `:is` pseudo class functions.\n\n```js\npostcss([\n  postcssIsPseudoClass({ onComplexSelector: 'warning' })\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n### onPseudoElement\n\nWarn when pseudo elements are used in `:is` pseudo class functions.\n\n⚠️ Pseudo elements are always invalid and will be transformed to `::-csstools-invalid-<pseudo-name>`.\n\n```js\npostcss([\n  postcssIsPseudoClass({ onPseudoElement: 'warning' })\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n```css\n:is(::after):hover {\n\torder: 1.0;\n}\n\n/* becomes */\n\n::-csstools-invalid-after:hover {\n\torder: 1.0;\n}\n```\n\n## ⚠️ Known shortcomings\n\n### Specificity\n\n`:is` takes the specificity of the most specific list item.\nWe can increase specificity with `:not` selectors, but we can't decrease it.\n\nConverted selectors are ensured to have the same specificity as `:is` for the most important bit.\nLess important bits can have higher specificity that `:is`.\n\nBefore :\n\n[specificity: 0, 2, 0](https://polypane.app/css-specificity-calculator/#selector=%3Ais(%3Ahover%2C%20%3Afocus)%3Ais(.button%2C%20button))\n\n```pcss\n:is(:hover, :focus):is(.button, button) {\n\torder: 7;\n}\n```\n\nAfter :\n\n```pcss\n/* specificity: [0, 2, 0] */\n.button:hover {\n\torder: 7;\n}\n\n/* specificity: [0, 2, 1] */\n/* last bit is higher than it should be, but middle bit matches */\nbutton:not(.does-not-exist):hover {\n\torder: 7;\n}\n\n/* specificity: [0, 2, 0] */\n.button:focus {\n\torder: 7;\n}\n\n/* specificity: [0, 2, 1] */\n/* last bit is higher than it should be, but middle bit matches */\nbutton:not(.does-not-exist):focus {\n\torder: 7;\n}\n```\n\n### Complex selectors\n\nBefore :\n\n\n```pcss\n:is(.alpha > .beta) ~ :is(:focus > .beta) {\n\torder: 2;\n}\n```\n\nAfter :\n\n```pcss\n.alpha > .beta ~ :focus > .beta {\n\torder: 2;\n}\n```\n\n_this is a different selector than expected as `.beta ~ :focus` matches `.beta` followed by `:focus`._<br>\n_avoid these cases._<br>\n_writing the selector without `:is()` is advised here_\n\n```pcss\n/* without is */\n.alpha:focus > .beta ~ .beta {\n\torder: 2;\n}\n```\n\nIf you have a specific pattern you can open an issue to discuss it.\nWe can detect and transform some cases but can't generalize them into a single solution that tackles all of them. \n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-img]: https://cssdb.org/images/badges/is-pseudo-class.svg\n[css-url]: https://cssdb.org/#is-pseudo-class\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-img]: https://img.shields.io/npm/v/@csstools/postcss-is-pseudo-class.svg\n[npm-url]: https://www.npmjs.com/package/@csstools/postcss-is-pseudo-class\n\n[CSS Selector]: https://www.w3.org/TR/selectors-4/#matches\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Is Pseudo Class]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class\n","publish_time":1681112899941,"_cnpm_publish_time":1681112899941,"dist-tags":{"latest":"6.0.3"}}