{"_id":"@csstools/postcss-is-pseudo-class@6.0.3","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"dist":{"shasum":"a4df821399c8d44db8faecfb93129bd043755449","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-is-pseudo-class/download/@csstools/postcss-is-pseudo-class-6.0.3.tgz","fileCount":6,"integrity":"sha512-7KJ7jiIdAAKaW82wFoKZqt2bXqE9Mwz4fm9YWWOIrC62o05daLpem1lnyIII6jbbCg6A6q4imWVDkiFIwFrcuQ==","signatures":[{"sig":"MEUCIQCnCjJTWX59YSkttVqql/V6hXS974PRYjw7QJnizlUnMgIgCAKby2Jo84Vst5aesrlR5BsIrUYmMxZvJAPQOGfFI6U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH/d4vgEvskuwGqUTkpH1mBhPwdrjzBwjLDNyO4CJv03AiAtDdVpTrrf/yCVsKJvGmiiYc2knlRlbvgt4TPIr2PQhQ=="}],"unpackedSize":19644,"size":6515,"noattachment":false,"key":"/@csstools/postcss-is-pseudo-class/-/@csstools/postcss-is-pseudo-class-6.0.3.tgz"},"name":"@csstools/postcss-is-pseudo-class","type":"module","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.mjs"}},"funding":[{"url":"https://github.com/sponsors/csstools","type":"github"},{"url":"https://opencollective.com/csstools","type":"opencollective"}],"gitHead":"2c6d90a0721caa6152eaa7d19bc52acf13573471","license":"MIT-0","scripts":{},"version":"6.0.3","_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class#readme","keywords":["css","is","matches","polyfill","postcss","postcss-plugin","pseudo","selector"],"repository":{"url":"git+https://github.com/csstools/postcss-plugins.git","type":"git","directory":"plugins/postcss-is-pseudo-class"},"_npmVersion":"11.13.0","description":"A pseudo-class for matching elements in a selector list","directories":{},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"romainmenke","email":"romainmenke@gmail.com"}],"_nodeVersion":"26.1.0","dependencies":{"postcss-selector-parser":"^7.1.1","@csstools/selector-specificity":"^6.0.1"},"_hasShrinkwrap":false,"peerDependencies":{"postcss":"^8.4"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/postcss-is-pseudo-class_6.0.3_1791230353703_0.017241395528772463"},"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/actions/workflows/test.yml/badge.svg?branch=main\" 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```css\n:is(input, button):is(:hover, :focus) {\n\torder: 1;\n}\n```\n\nBecomes :\n\n```css\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```css\n:is(input, button):is(:hover, :focus) {\n\torder: 1;\n}\n```\n\nBecomes :\n\n```css\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```css\n:is(.button, button):hover {\n\torder: 7;\n}\n```\n\nBecomes :\n\n```css\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```css\n:is(:hover, :focus):is(.button, button) {\n\torder: 7;\n}\n```\n\nAfter :\n\n```css\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```css\n:is(.alpha > .beta) ~ :is(:focus > .beta) {\n\torder: 2;\n}\n```\n\nAfter :\n\n```css\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```css\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":1791230353786,"_cnpm_publish_time":1791230353786,"dist-tags":{"latest":"6.0.3"}}