{"name":"@csstools/postcss-is-pseudo-class","description":"A pseudo-class for matching elements in a selector list","version":"2.0.7","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","funding":{"type":"opencollective","url":"https://opencollective.com/csstools"},"engines":{"node":"^12 || ^14 || >=16"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"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.2"},"devDependencies":{"puppeteer":"^15.1.1"},"scripts":{"build":"rollup -c ../../rollup/default.js","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"","docs":"node ../../.github/bin/generate-docs/install.mjs","lint":"npm run lint:eslint && npm run lint:package-json","lint:eslint":"eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern","lint:package-json":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run clean && npm run build && npm run test","stryker":"stryker run --logLevel error","test":"node .tape.mjs && npm run test:exports","test:browser":"node ./test/_browser.mjs","test:exports":"node ./test/_import.mjs && node ./test/_require.cjs","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":"cc4034504d92faec8c4b847c2d815a6a80074c16","_id":"@csstools/postcss-is-pseudo-class@2.0.7","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-7JPeVVZHd+jxYdULl87lvjgvWldYu+Bc62s9vD/ED6/QTGjy0jy0US/f6BG53sVMTBJ1lzKZFpYmofBN9eaRiA==","shasum":"846ae6c0d5a1eaa878fce352c544f9c295509cd1","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-is-pseudo-class/download/@csstools/postcss-is-pseudo-class-2.0.7.tgz","fileCount":12,"unpackedSize":29488,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyYZzQV9ISkno2KqJxIYgtcLgAdDgNcqScehcOe4911QIhAJCzj9oh34nGBBAO7I95l81Vzad83QKf3XdbpX6eYjUr"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiyGF/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBXBAAihzn2KqQyMLoJPPvUYKIAgwhFJa8EN8niW6lTN84tj5YWtgQ\r\n2XOmthyIY3/f9DVhQ4ShFmJBEza+f31QHb6k6O5haDjFyAzVGWI3PJPfeiJZ\r\nIKZxcOarudXSLrBnhNMouMziXQ954XXQezb2s5Qjsco2b3W9f7g5Z5wGh/Jk\r\noPimPPY6dg8J9jhoUGHzO94r9EICt4KoAUh3fBFlYheBdkPw1GHRFsoP+gAE\r\nOsY/49g6InRHns7vZtqPoWuglwhtyx6IydsYJWW4uVI2kHKITZE8MFJ/BS3+\r\n3zPOA6kBVndArBbqPP6XzhKKdUgRkOkxe1cx86nqQaTeQe/kRjt+zwrhfX2a\r\nri+izNrD8ZbIHsjswiBMtLYmWOf8xiQQ/W+olwh9bXUx+X9jdE6bKdJ8eIHk\r\nfXE/vAXoMjLVqv5K66nH3LP1MeAHFsmUhjqRLV9NhnDVd/74BfHgQLBxZRLK\r\n7G0LmO0R9O69ObfSX4fsFi2T/vqUDQxyz/QTI6xs1hVjtoSpEv/9LjAuTz4O\r\nStWM9kqGVkspxL5ioS031N2i4W8C12vg6ac0/TR0ptUxiKseXmPm2VPuJry3\r\nGqKpgs8uG8JIGY9JSIZL51CUto/l3FFm5qu4terae3iBo9ll+/1nTtazZYXG\r\nxFEgldBXWbyAcHtHpUBTjbI21DPSSNATMKY=\r\n=7afT\r\n-----END PGP SIGNATURE-----\r\n","size":9134,"noattachment":false,"key":"/@csstools/postcss-is-pseudo-class/-/@csstools/postcss-is-pseudo-class-2.0.7.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_2.0.7_1657299326914_0.6095091378419049"},"_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":1657299327181,"_cnpm_publish_time":1657299327181,"dist-tags":{"latest":"6.0.3"}}