Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to have alias field for CSS features #1427

Open
OnkarRuikar opened this issue Jan 2, 2025 · 2 comments
Open

Need to have alias field for CSS features #1427

OnkarRuikar opened this issue Jan 2, 2025 · 2 comments

Comments

@OnkarRuikar
Copy link

For example, the font-stretch property was renamed to font-width. No browser has updated this change. So we have to keep font-stretch page in the docs. Is there any way to reach font-width syntax using font-stretch as input?

Can we add alias property to the CSS features? For example, in this case, add "aliases: ['font-stretch']", to the font-width definition:

"name": "font-width",
"href": "https://www.w3.org/TR/css-fonts-4/#propdef-font-width",
"value": "normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded",
"initial": "normal",
"appliesTo": "all elements and text",
"inherited": "yes",
"percentages": "Not resolved",
"computedValue": "a percentage, see below",
"canonicalOrder": "per grammar",
"animationType": "by computed value type",
"values": [

@tidoust
Copy link
Member

tidoust commented Jan 16, 2025

Oh, I missed this issue for some reason, sorry for the delay in responding, @OnkarRuikar!

For example, the font-stretch property was renamed to font-width. No browser has updated this change. So we have to keep font-stretch page in the docs.

Reformulating a bit differently to scope what I understand is the feature request here: font-stretch did not disappear, it's still defined in CSS Fonts Level 4 and present in the extract, but it's defined as a legacy name alias of font-width, and that relationship is not currently captured by the crawler.

Is there any way to reach font-width syntax using font-stretch as input?

Not now, but that's something that has been pending for a few years already, see w3c/reffy#538, which originated from #115 (comment).

Looking at specs that reference "legacy name alias", I end up with the following list:

It's certainly worth capturing the alias information somehow. Approaches that come to mind:

  • Ideally, the crawler would be able to figure that out on its own, but I'm not sure it's going to be easy to capture definitions hidden in prose. That would be the preferred approach coz it'd be automatic.
  • A patching approach is probably going to be cumbersome. Patches are meant to be temporary, these patches would stay forever and the list will grow over time.
  • Alternatively, a curation script similar to tools/drop-css-property-duplicates.js could amend the extracts to add the alias links. Maintaining the list of links to add would remain manual, but the list would be at least easier to amend than a file patch.

@OnkarRuikar
Copy link
Author

The curation script sounds good. We can hard code known aliases there.

tidoust added a commit to w3c/reffy that referenced this issue Jan 20, 2025
CSS specs sometimes define property names that are "legacy name aliases" of
another property name. Reffy extracted the legacy property names (during
post-processing) as they are defined in a `<dfn>` element but did not flag
them in any way.

The crawler now adds a `legacyAliasOf` key to the property in the CSS extract
whose value is the name of the aliased property.

Extraction is based on looking for links to the term "legacy name alias"
(defined in CSS Cascade 4 and 5) and simple patterns around it. Either:
1. a dfn for a property followed by a reference to the aliased property; or
2. a table with two columns: dfns in the first column, references to the
aliased properties in the second column.

First case handles legacy definitions in `css-align-3`, `css-fonts-4`,
and `css-ui-4`. Second case handles legacy definitions in `compat`.

Legacy definitions in `css-text-3` and `css-text-4` are not extracted... and
that is a good thing because they define `word-wrap` both as an actual property
and as a legacy name alias of `overflow-wrap`, which seems wrong.

Legacy definitions in `css-flexbox-1` are not extracted either... which also
is a good thing given that `compat` handles them already!

The `css-ui-4` spec also defines `-webkit-user-select` as an alias of
`user-select`, but the spec does not use the "legacy name alias" mechanism,
apparently on purpose:
https://drafts.csswg.org/css-ui-4/#propdef--webkit-user-select
That relationship will have to be added with a patch if we really want it.

Fixes #538 (although note there will remain a few CSS properties in extracts
that do not have a real "value") and w3c/webref#1427
tidoust added a commit to w3c/reffy that referenced this issue Jan 21, 2025
CSS specs sometimes define property names that are "legacy name aliases" of
another property name. Reffy extracted the legacy property names (during
post-processing) as they are defined in a `<dfn>` element but did not flag
them in any way.

The crawler now adds a `legacyAliasOf` key to the property in the CSS extract
whose value is the name of the aliased property.

Extraction is based on looking for links to the term "legacy name alias"
(defined in CSS Cascade 4 and 5) and simple patterns around it. Either:
1. a dfn for a property followed by a reference to the aliased property; or
2. a table with two columns: dfns in the first column, references to the
aliased properties in the second column.

First case handles legacy definitions in `css-align-3`, `css-fonts-4`,
and `css-ui-4`. Second case handles legacy definitions in `compat`.

Legacy definitions in `css-text-3` and `css-text-4` are not extracted... and
that is a good thing because they define `word-wrap` both as an actual property
and as a legacy name alias of `overflow-wrap`, which seems wrong.

Legacy definitions in `css-flexbox-1` are not extracted either... which also
is a good thing given that `compat` handles them already!

The `css-ui-4` spec also defines `-webkit-user-select` as an alias of
`user-select`, but the spec does not use the "legacy name alias" mechanism,
apparently on purpose:
https://drafts.csswg.org/css-ui-4/#propdef--webkit-user-select
That relationship will have to be added with a patch if we really want it.

Fixes #538 (although note there will remain a few CSS properties in extracts
that do not have a real "value") and w3c/webref#1427

Co-authored-by: Dominique Hazael-Massieux <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants