summaryrefslogtreecommitdiff
path: root/node_modules/@csstools/selector-specificity
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/@csstools/selector-specificity
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/@csstools/selector-specificity')
-rw-r--r--node_modules/@csstools/selector-specificity/CHANGELOG.md24
-rw-r--r--node_modules/@csstools/selector-specificity/LICENSE.md18
-rw-r--r--node_modules/@csstools/selector-specificity/README.md57
-rw-r--r--node_modules/@csstools/selector-specificity/dist/index.cjs1
-rw-r--r--node_modules/@csstools/selector-specificity/dist/index.d.ts58
-rw-r--r--node_modules/@csstools/selector-specificity/dist/index.mjs1
-rw-r--r--node_modules/@csstools/selector-specificity/package.json65
7 files changed, 0 insertions, 224 deletions
diff --git a/node_modules/@csstools/selector-specificity/CHANGELOG.md b/node_modules/@csstools/selector-specificity/CHANGELOG.md
deleted file mode 100644
index c3ca9230..00000000
--- a/node_modules/@csstools/selector-specificity/CHANGELOG.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Changes to Selector Specificity
-
-### 3.1.1
-
-_May 13, 2024_
-
-- Prevent mutation of selectors with An+B microsyntax (e.g. `:nth-child(2n+1 of .foo)`) during specificity calculation
-
-### 3.1.0
-
-_May 11, 2024_
-
-- Add an option to `selectorSpecificity` and `specificityOfMostSpecificListItem` to customize the calculation
-- Add `specificityOfMostSpecificListItem` as an exported function
-
-### 3.0.3
-
-_March 31, 2024_
-
-- Add support for:
- - `:active-view-transition`
- - `:active-view-transition-type(foo)`
-
-[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity/CHANGELOG.md)
diff --git a/node_modules/@csstools/selector-specificity/LICENSE.md b/node_modules/@csstools/selector-specificity/LICENSE.md
deleted file mode 100644
index e8ae93b9..00000000
--- a/node_modules/@csstools/selector-specificity/LICENSE.md
+++ /dev/null
@@ -1,18 +0,0 @@
-MIT No Attribution (MIT-0)
-
-Copyright © CSSTools Contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the “Software”), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/node_modules/@csstools/selector-specificity/README.md b/node_modules/@csstools/selector-specificity/README.md
deleted file mode 100644
index 3868d7d0..00000000
--- a/node_modules/@csstools/selector-specificity/README.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# Selector Specificity
-
-[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/selector-specificity.svg" height="20">][npm-url]
-[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
-[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
-
-## Usage
-
-Add [Selector Specificity] to your project:
-
-```bash
-npm install @csstools/selector-specificity --save-dev
-```
-
-```js
-import parser from 'postcss-selector-parser';
-import { selectorSpecificity } from '@csstools/selector-specificity';
-
-const selectorAST = parser().astSync('#foo:has(> .foo)');
-const specificity = selectorSpecificity(selectorAST);
-
-console.log(specificity.a); // 1
-console.log(specificity.b); // 1
-console.log(specificity.c); // 0
-```
-
-_`selectorSpecificity` takes a single selector, not a list of selectors (not : `a, b, c`).
-To compare or otherwise manipulate lists of selectors you need to call `selectorSpecificity` on each part._
-
-### Comparing
-
-The package exports a utility function to compare two specificities.
-
-```js
-import { selectorSpecificity, compare } from '@csstools/selector-specificity';
-
-const s1 = selectorSpecificity(ast1);
-const s2 = selectorSpecificity(ast2);
-compare(s1, s2); // -1 | 0 | 1
-```
-
-- if `s1 < s2` then `compare(s1, s2)` returns a negative number (`< 0`)
-- if `s1 > s2` then `compare(s1, s2)` returns a positive number (`> 0`)
-- if `s1 === s2` then `compare(s1, s2)` returns zero (`=== 0`)
-
-## Prior Art
-
-- [keeganstreet/specificity](https://github.com/keeganstreet/specificity)
-- [bramus/specificity](https://github.com/bramus/specificity)
-
-For CSSTools we always use `postcss-selector-parser` and want to calculate specificity from this AST.
-
-[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
-[discord]: https://discord.gg/bUadyRwkJS
-[npm-url]: https://www.npmjs.com/package/@csstools/selector-specificity
-
-[Selector Specificity]: https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity
diff --git a/node_modules/@csstools/selector-specificity/dist/index.cjs b/node_modules/@csstools/selector-specificity/dist/index.cjs
deleted file mode 100644
index 22f96490..00000000
--- a/node_modules/@csstools/selector-specificity/dist/index.cjs
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var e=require("postcss-selector-parser");function compare(e,t){return e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a}function selectorSpecificity(t,s){const i=s?.customSpecificity?.(t);if(i)return i;if(!t)return{a:0,b:0,c:0};let c=0,n=0,o=0;if("universal"==t.type)return{a:0,b:0,c:0};if("id"===t.type)c+=1;else if("tag"===t.type)o+=1;else if("class"===t.type)n+=1;else if("attribute"===t.type)n+=1;else if(isPseudoElement(t))switch(t.value.toLowerCase()){case"::slotted":if(o+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return t.nodes&&1===t.nodes.length&&"selector"===t.nodes[0].type&&selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:o+=1}else if(e.isPseudoClass(t))switch(t.value.toLowerCase()){case":-webkit-any":case":any":default:n+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(n+=1,t.nodes&&t.nodes.length>0){const i=t.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===e.value.toLowerCase()));if(i>-1){const a=e.selector({nodes:[],value:""});t.nodes[0].nodes.slice(i+1).forEach((e=>{a.append(e.clone())}));const r=[a];t.nodes.length>1&&r.push(...t.nodes.slice(1));const l=specificityOfMostSpecificListItem(r,s);c+=l.a,n+=l.b,o+=l.c}}break;case":local":case":global":t.nodes&&t.nodes.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));break;case":host":case":host-context":if(n+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(t)&&t.nodes?.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));return{a:c,b:n,c:o}}function specificityOfMostSpecificListItem(e,t){let s={a:0,b:0,c:0};return e.forEach((e=>{const i=selectorSpecificity(e,t);compare(i,s)<0||(s=i)})),s}function isPseudoElement(t){return e.isPseudoElement(t)}function selectorNodeContainsNothingOrOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const t=e.nodes.filter((e=>"comment"!==e.type));return 0===t.length||1===t.length&&"universal"===t[0].type}exports.compare=compare,exports.selectorSpecificity=selectorSpecificity,exports.specificityOfMostSpecificListItem=specificityOfMostSpecificListItem;
diff --git a/node_modules/@csstools/selector-specificity/dist/index.d.ts b/node_modules/@csstools/selector-specificity/dist/index.d.ts
deleted file mode 100644
index f3f959d3..00000000
--- a/node_modules/@csstools/selector-specificity/dist/index.d.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import type { Node } from 'postcss-selector-parser';
-
-/**
- * Options for the calculation of the specificity of a selector
- */
-export declare type CalculationOptions = {
- /**
- * The callback to calculate a custom specificity for a node
- */
- customSpecificity?: CustomSpecificityCallback;
-};
-
-/**
- * Compare two specificities
- * @param s1 The first specificity
- * @param s2 The second specificity
- * @returns A value smaller than `0` if `s1` is less specific than `s2`, `0` if `s1` is equally specific as `s2`, a value larger than `0` if `s1` is more specific than `s2`
- */
-export declare function compare(s1: Specificity, s2: Specificity): number;
-
-/**
- * Calculate a custom specificity for a node
- */
-export declare type CustomSpecificityCallback = (node: Node) => Specificity | void | false | null | undefined;
-
-/**
- * Calculate the specificity for a selector
- */
-export declare function selectorSpecificity(node: Node, options?: CalculationOptions): Specificity;
-
-/**
- * The specificity of a selector
- */
-export declare type Specificity = {
- /**
- * The number of ID selectors in the selector
- */
- a: number;
- /**
- * The number of class selectors, attribute selectors, and pseudo-classes in the selector
- */
- b: number;
- /**
- * The number of type selectors and pseudo-elements in the selector
- */
- c: number;
-};
-
-/**
- * Calculate the most specific selector in a list
- */
-export declare function specificityOfMostSpecificListItem(nodes: Array<Node>, options?: CalculationOptions): {
- a: number;
- b: number;
- c: number;
-};
-
-export { }
diff --git a/node_modules/@csstools/selector-specificity/dist/index.mjs b/node_modules/@csstools/selector-specificity/dist/index.mjs
deleted file mode 100644
index b6c4e1cb..00000000
--- a/node_modules/@csstools/selector-specificity/dist/index.mjs
+++ /dev/null
@@ -1 +0,0 @@
-import e from"postcss-selector-parser";function compare(e,t){return e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a}function selectorSpecificity(t,s){const i=s?.customSpecificity?.(t);if(i)return i;if(!t)return{a:0,b:0,c:0};let c=0,n=0,o=0;if("universal"==t.type)return{a:0,b:0,c:0};if("id"===t.type)c+=1;else if("tag"===t.type)o+=1;else if("class"===t.type)n+=1;else if("attribute"===t.type)n+=1;else if(isPseudoElement(t))switch(t.value.toLowerCase()){case"::slotted":if(o+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return t.nodes&&1===t.nodes.length&&"selector"===t.nodes[0].type&&selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:o+=1}else if(e.isPseudoClass(t))switch(t.value.toLowerCase()){case":-webkit-any":case":any":default:n+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(n+=1,t.nodes&&t.nodes.length>0){const i=t.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===e.value.toLowerCase()));if(i>-1){const a=e.selector({nodes:[],value:""});t.nodes[0].nodes.slice(i+1).forEach((e=>{a.append(e.clone())}));const r=[a];t.nodes.length>1&&r.push(...t.nodes.slice(1));const l=specificityOfMostSpecificListItem(r,s);c+=l.a,n+=l.b,o+=l.c}}break;case":local":case":global":t.nodes&&t.nodes.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));break;case":host":case":host-context":if(n+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(t)&&t.nodes?.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));return{a:c,b:n,c:o}}function specificityOfMostSpecificListItem(e,t){let s={a:0,b:0,c:0};return e.forEach((e=>{const i=selectorSpecificity(e,t);compare(i,s)<0||(s=i)})),s}function isPseudoElement(t){return e.isPseudoElement(t)}function selectorNodeContainsNothingOrOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const t=e.nodes.filter((e=>"comment"!==e.type));return 0===t.length||1===t.length&&"universal"===t[0].type}export{compare,selectorSpecificity,specificityOfMostSpecificListItem};
diff --git a/node_modules/@csstools/selector-specificity/package.json b/node_modules/@csstools/selector-specificity/package.json
deleted file mode 100644
index ce426825..00000000
--- a/node_modules/@csstools/selector-specificity/package.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "name": "@csstools/selector-specificity",
- "description": "Determine selector specificity with postcss-selector-parser",
- "version": "3.1.1",
- "contributors": [
- {
- "name": "Antonio Laguna",
- "email": "antonio@laguna.es",
- "url": "https://antonio.laguna.es"
- },
- {
- "name": "Romain Menke",
- "email": "romainmenke@gmail.com"
- }
- ],
- "license": "MIT-0",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/csstools"
- },
- {
- "type": "opencollective",
- "url": "https://opencollective.com/csstools"
- }
- ],
- "engines": {
- "node": "^14 || ^16 || >=18"
- },
- "type": "module",
- "main": "dist/index.cjs",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "import": {
- "types": "./dist/index.d.ts",
- "default": "./dist/index.mjs"
- },
- "require": {
- "default": "./dist/index.cjs"
- }
- }
- },
- "files": [
- "CHANGELOG.md",
- "LICENSE.md",
- "README.md",
- "dist"
- ],
- "peerDependencies": {
- "postcss-selector-parser": "^6.0.13"
- },
- "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity#readme",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/csstools/postcss-plugins.git",
- "directory": "packages/selector-specificity"
- },
- "bugs": "https://github.com/csstools/postcss-plugins/issues",
- "keywords": [
- "css",
- "postcss-selector-parser",
- "specificity"
- ]
-}