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

Fix extracting CSS variables with default value #18

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

hyrious
Copy link
Collaborator

@hyrious hyrious commented Feb 7, 2023

There are 2 issues in previous code:

  1. Applying CSS variables wrongly handled non-exist variables, resulting undefined at value. It should be left as is.

  2. GitHub added 2 new CSS variables with default fallback, previously the script does not handle this case well, it can correctly extract them now.

@sindresorhus sindresorhus merged commit 06342a1 into main Feb 9, 2023
@sindresorhus sindresorhus deleted the fix-css-var-def branch February 9, 2023 10:05
@sindresorhus
Copy link
Owner

When generating, I noticed that it now includes some things we don't want, like [data-dev-analytics-enabled]. Would you be able to remove that?

@hyrious
Copy link
Collaborator Author

hyrious commented Feb 9, 2023

I'd like to, looks like these unwanted styles are extracted from top level rules (since they may have chance to affect markdown body).

Previously we only have one forbidden rule [hidden][hidden], maybe it's time to disallow more selectors.

Let's print out these selectors to have a glance (omitting '.class', ':root', '::-webkit-whatever', 'p'..):

[data-color-mode=light][data-light-theme*=light]
[data-color-mode=dark][data-dark-theme*=light]
[data-color-mode=light][data-light-theme*=dark]
[data-color-mode=dark][data-dark-theme*=dark]
[data-color-mode]
[hidden]
[type=reset]
[type=submit]
[type=checkbox]
[type=radio]
[type=number]::-webkit-inner-spin-button
[type=number]::-webkit-outer-spin-button
[type=search]::-webkit-search-cancel-button
[type=search]::-webkit-search-decoration
[role=button]:focus
[role=button]:focus:not(:focus-visible)
[role=button]:focus-visible
[data-catalyst]
[data-catalyst-inline]
[data-a11y-animated-images=system] [data-animated-image]
[data-a11y-animated-images=disabled] [data-animated-image]
[data-color-mode=light][data-light-theme*=dark] ::selection
[data-color-mode=dark][data-dark-theme*=dark] ::selection
[data-dev-analytics-enabled] [data-feeds-analytics]
[data-dev-analytics-enabled] [data-feeds-analytics]::after
[data-dev-analytics-enabled] [data-feeds-analytics]:hover
[data-dev-analytics-enabled] [data-feeds-analytics]:hover::after

@sindresorhus
Copy link
Owner

maybe it's time to disallow more selectors.

👍

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.

2 participants