From 146d48f6af3dc4b50973365670c61cb08cc39098 Mon Sep 17 00:00:00 2001 From: Bart Veneman Date: Fri, 9 Aug 2024 14:42:22 +0200 Subject: [PATCH] use `calculateSelectorNode` for calculating specificity --- package-lock.json | 15 ++++++++------- package.json | 2 +- src/index.js | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 11fdab0..cb83a95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "5.15.0", "license": "MIT", "dependencies": { - "@bramus/specificity": "^2.3.0", + "@bramus/specificity": "github:bartveneman/specificity#be1f89dea482a366b9ed5bd49ef3e8af4d9ccb34", "css-tree": "^2.3.1" }, "devDependencies": { @@ -22,7 +22,7 @@ "vite-plugin-dts": "^3.9.1" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18.0.0" } }, "node_modules/@babel/parser": { @@ -47,8 +47,9 @@ }, "node_modules/@bramus/specificity": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.3.0.tgz", - "integrity": "sha512-up0RtrNYEd3Q5fadLnsG000H/BfbHrRHwENQGZn7BB/36VtusPNAVblbkV+CtKSIOs16Nkss8d9fHYIoKeVN9g==", + "resolved": "git+ssh://git@github.com/bartveneman/specificity.git#be1f89dea482a366b9ed5bd49ef3e8af4d9ccb34", + "integrity": "sha512-YR9CbDoCY5+/0xNgkLAwyGOTX2xZytu1K4BR1r1gLf/92PJ1nr5rVa6SaIw6GsIjR8+OiuzIP8m7bWbXF552+g==", + "license": "MIT", "dependencies": { "css-tree": "^2.3.1" }, @@ -3152,9 +3153,9 @@ "dev": true }, "@bramus/specificity": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.3.0.tgz", - "integrity": "sha512-up0RtrNYEd3Q5fadLnsG000H/BfbHrRHwENQGZn7BB/36VtusPNAVblbkV+CtKSIOs16Nkss8d9fHYIoKeVN9g==", + "version": "git+ssh://git@github.com/bartveneman/specificity.git#be1f89dea482a366b9ed5bd49ef3e8af4d9ccb34", + "integrity": "sha512-YR9CbDoCY5+/0xNgkLAwyGOTX2xZytu1K4BR1r1gLf/92PJ1nr5rVa6SaIw6GsIjR8+OiuzIP8m7bWbXF552+g==", + "from": "@bramus/specificity@github:bartveneman/specificity#be1f89dea482a366b9ed5bd49ef3e8af4d9ccb34", "requires": { "css-tree": "^2.3.1" } diff --git a/package.json b/package.json index 147dc6a..84445cd 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "code" ], "dependencies": { - "@bramus/specificity": "^2.3.0", + "@bramus/specificity": "github:bartveneman/specificity#be1f89dea482a366b9ed5bd49ef3e8af4d9ccb34", "css-tree": "^2.3.1" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index 251f519..4289e19 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ import parse from 'css-tree/parser' import walk from 'css-tree/walker' -import { calculate } from '@bramus/specificity/core' +import { calculateSelectorNode } from '@bramus/specificity/core' import { isSupportsBrowserhack, isMediaBrowserhack } from './atrules/atrules.js' import { getCombinators, getComplexity, isAccessibility, isPrefixed } from './selectors/utils.js' import { colorFunctions, colorKeywords, namedColors, systemColors } from './values/colors.js' @@ -318,7 +318,7 @@ export function analyze(css, options = {}) { uniqueSelectorComplexities.p(complexity, node.loc) // #region specificity - let [{ value: specificityObj }] = calculate(node) + let specificityObj = calculateSelectorNode(node) let sa = specificityObj.a let sb = specificityObj.b let sc = specificityObj.c