Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"prettier": "3.9.6",
"tailwind-csstree": "^0.4.0",
"typescript": "^7.0.2",
"web-features": "^3.37.0",
"web-features": "^3.38.0",
"yorkie": "^2.0.0"
},
"engines": {
Expand Down
13 changes: 8 additions & 5 deletions src/data/baseline-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const properties = new Map([
["line-break", "10:2020"],
["line-clamp", "0:"],
["line-height", "10:2015"],
["link-parameters", "0:"],
["list-style", "10:2015"],
["list-style-image", "10:2015"],
["list-style-position", "10:2015"],
Expand Down Expand Up @@ -466,8 +467,8 @@ export const properties = new Map([
["marker-mid", "10:2017"],
["marker-start", "10:2017"],
["r", "10:2020"],
["rx", "5:2024"],
["ry", "5:2024"],
["rx", "10:2024"],
["ry", "10:2024"],
["shape-rendering", "10:2020"],
["stop-color", "10:2017"],
["stop-opacity", "10:2017"],
Expand Down Expand Up @@ -526,7 +527,7 @@ export const properties = new Map([
["text-transform", "10:2015"],
["text-underline-offset", "10:2020"],
["text-underline-position", "10:2020"],
["text-wrap", "5:2024"],
["text-wrap", "10:2024"],
["text-wrap-mode", "5:2024"],
["text-wrap-style", "5:2024"],
["touch-action", "10:2019"],
Expand Down Expand Up @@ -636,7 +637,6 @@ export const functions = new Map([
["attr", "10:2015"],
["calc", "10:2015"],
["calc-size", "0:"],
["shape", "5:2026"],
["rect", "10:2024"],
["color", "10:2023"],
["color-mix", "10:2023"],
Expand Down Expand Up @@ -683,6 +683,7 @@ export const functions = new Map([
["lab", "10:2023"],
["lch", "10:2023"],
["light-dark", "5:2024"],
["param", "0:"],
["clamp", "10:2020"],
["max", "10:2020"],
["min", "10:2020"],
Expand All @@ -698,6 +699,7 @@ export const functions = new Map([
["mod", "5:2024"],
["rem", "5:2024"],
["env", "10:2020"],
["shape", "5:2026"],
["circle", "10:2020"],
["ellipse", "10:2020"],
["inset", "10:2020"],
Expand Down Expand Up @@ -2818,6 +2820,7 @@ export const propertyValues = new Map([
],
["line-clamp", new Map([["none", "0:"]])],
["line-height", new Map([["normal", "10:2015"]])],
["link-parameters", new Map([["none", "0:"]])],
["list-style-image", new Map([["none", "10:2015"]])],
[
"list-style-position",
Expand Down Expand Up @@ -3938,7 +3941,7 @@ export const propertyValues = new Map([
new Map([
["auto", "10:2021"],
["from-font", "10:2021"],
["percentage", "5:2024"],
["percentage", "10:2024"],
]),
],
[
Expand Down
33 changes: 29 additions & 4 deletions tools/generate-baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ const groupedUnitMappings = {
/*
* Some bare `css.types.<name>` compat keys refer to CSS data types
* instead of functions. For example, `css.types.image` refers to `<image>`,
* not `image()`.
* not `image()`, and `css.types.shape` refers to the deprecated `<shape>`
* type used by `clip`, not `shape()`.
*/
const UNGROUPED_NON_FUNCTION_TYPES = new Set(["color", "image", "string"]);
const UNGROUPED_NON_FUNCTION_TYPES = new Set([
"color",
"image",
"shape",
"string",
]);

const BASELINE_HIGH = 10;
const BASELINE_LOW = 5;
Expand Down Expand Up @@ -172,10 +178,24 @@ function extractCSSFeatures(features) {
units: {},
};

/*
* Functions whose status came from their own bare `css.types.<name>`
* compat key. That key is the compat entry for the function itself, so it
* takes precedence over a feature name match and over grouped
* `css.types.<group>.<name>` keys, which describe a sub-feature of
* `<group>` that merely shares the name. For example,
* `css.types.param.url` describes `param()` inside `url()`, not `url()`.
*/
const functionsFromBareKeys = new Set();

for (const feature of Object.values(features)) {
// Check if the feature name itself represents a function
const nameMatch = PATTERNS.functionName.exec(feature.name);
if (nameMatch && isKnownCSSFunction(nameMatch.groups.name)) {
if (
nameMatch &&
isKnownCSSFunction(nameMatch.groups.name) &&
!functionsFromBareKeys.has(nameMatch.groups.name)
) {
output.functions[nameMatch.groups.name] = mapFeatureStatus(
feature.status,
);
Expand Down Expand Up @@ -258,7 +278,12 @@ function extractCSSFeatures(features) {
else if ((match = PATTERNS.type.exec(key))) {
const { group, type } = match.groups;
if (isCompatTypeAFunction(group, type)) {
output.functions[type] = mapFeatureStatus(status);
if (!group) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this logic would be easier to understand like this:

if (!functionsFromBareKeys.has(type)) {
	output.functions[type] = mapFeatureStatus(status);
}

if (!group) {
	functionsFromBareKeys.add(type);
}

The logic should be equivalent (currently produces the same output).

functionsFromBareKeys.add(type);
output.functions[type] = mapFeatureStatus(status);
} else if (!functionsFromBareKeys.has(type)) {
output.functions[type] = mapFeatureStatus(status);
}
}
}
// selectors
Expand Down