{"name":"@csstools/postcss-is-pseudo-class","version":"2.0.0","description":"A pseudo-class for matching elements in a selector list","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class#readme","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"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"}},"scripts":{"build":"rollup -c ../../rollup/default.js","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"","lint":"eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern","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:rewrite-expects":"REWRITE_EXPECTS=true node .tape.mjs","test:exports":"node ./test/_import.mjs && node ./test/_require.cjs"},"dependencies":{"postcss-selector-parser":"^6.0.9"},"peerDependencies":{"postcss":"^8.4"},"devDependencies":{"puppeteer":"^13.1.2"},"keywords":["postcss","css","postcss-plugin","matches","is","selector","polyfill","pseudo"],"repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"plugins/postcss-is-pseudo-class"},"volta":{"extends":"../../package.json"},"gitHead":"f1f7746937c7eedd5c2b383064049313f7b10911","_id":"@csstools/postcss-is-pseudo-class@2.0.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-WnfZlyuh/CW4oS530HBbrKq0G8BKl/bsNr5NMFoubBFzJfvFRGJhplCgIJYWUidLuL3WJ/zhMtDIyNFTqhx63Q==","shasum":"219a1c1d84de7d9e9b7e662a57fdc194eac38ea7","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-is-pseudo-class/download/@csstools/postcss-is-pseudo-class-2.0.0.tgz","fileCount":13,"unpackedSize":29342,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh95TLCRA9TVsSAnZWagAA8isP/2kUnmPXp6Hy6qTnaO5D\nQij9Xl63BgotE5CXaizgtQUIYUd46mA4DWZMVpfWdA0i6Pl1UiN/YzgG/7z1\n2eGD6wthzDZ9KdVYrTvyaIcM419hVg6XvYrxWlS6rArgb2Hqq/a6WZmpg025\nJ8d+eSr/SMKxswG2p9gbMSASeWKY8HGcTvtu/G15CEblSZ3LtkjHhwqCKywZ\n96fHB5R1F+aYk82uQP+ebx1HgoAWf8GnzBOBgsvFbvQO+GB6jk/wP5ZRGtro\ntbYyHwaUI1hGh9z0bt2jzfS5uI9wADqk0aGDNgf4XjpOoo1p6ck4cJQVvL55\n1sJ24UGG+ITdiNxL9CMNpfp7SurzDU3JR8mwWxE3N5a476fbiJC+hMi2cDSx\nZpyEKWUIQLG3XUibUJOkDZmRQoH5ntN4TNCG2r0LqRJGo63EW2VP9GaHmL/g\n/mhfCzyEcm1VXRXL4P70s5oe2LQfsaCSzenWXPFRYMJAP61VERCMy0dxe5iO\nBqipu4WZt1pshnoYPkZHWdUtAVWMZn1zzwHDx47yl1llj5QOGNEC4zHvPZyD\nSvv6pNJwn+LMvESL9Uv/QDGbUjRTg+bxeFcUwxtgt/y3Ve3GdiwIgKf9hd59\nMiHtu5xRtpbQm8Z6RzSMinskZAEqqlItMDNbxp2HlneRMU9WlYM3R8PyJMLy\ndPsS\r\n=lOiN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFYM4/pAAbFu9++/ZtjI2mgIr2Uo/bW67Y0kdLB51udEAiEAmCTqnJPKKc8oJoNpr5OcCssAUM8wcyHZ25mCmMoNBnI="}],"size":8863,"noattachment":false,"key":"/@csstools/postcss-is-pseudo-class/-/@csstools/postcss-is-pseudo-class-2.0.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_2.0.0_1643615435719_0.6578982664578821"},"_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":1643615435883,"_cnpm_publish_time":1643615435883,"dist-tags":{"latest":"6.0.3"}}