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

Extract CSS legacy name aliases defined in specs #1753

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented 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, possibly on purpose. 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

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 tidoust requested a review from dontcallmedom January 20, 2025 21:56
Copy link
Member

@dontcallmedom dontcallmedom left a comment

Choose a reason for hiding this comment

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

Nice!

A couple of suggested minor improvements for your consideration

src/browserlib/extract-cssdfn.mjs Outdated Show resolved Hide resolved
src/browserlib/extract-cssdfn.mjs Outdated Show resolved Hide resolved
tidoust and others added 2 commits January 21, 2025 09:06
Co-authored-by: Dominique Hazael-Massieux <[email protected]>
Co-authored-by: Dominique Hazael-Massieux <[email protected]>
@tidoust
Copy link
Member Author

tidoust commented Jan 21, 2025

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.

Raised in w3c/csswg-drafts#11544

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

Raised in w3c/csswg-drafts#11545

@tidoust tidoust merged commit 0e8e058 into main Jan 21, 2025
1 check passed
@tidoust tidoust deleted the css-legacy-alias branch January 21, 2025 08:08
tidoust added a commit that referenced this pull request Jan 21, 2025
New feature:
- Extract CSS legacy name aliases defined in specs (#1753)

Dependencies bumped:
- Bump commander from 13.0.0 to 13.1.0 (#1755)
- Bump web-specs from 3.34.0 to 3.35.0 (#1754)
- Bump rollup from 4.30.1 to 4.31.0 (#1752)
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

Successfully merging this pull request may close these issues.

Improve extracts for legacy and aliases CSS properties
2 participants