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

{{CSSXref}} handles CSS functions incorrectly #8755

Closed
3 tasks done
yarusome opened this issue May 4, 2023 · 2 comments · Fixed by #8766
Closed
3 tasks done

{{CSSXref}} handles CSS functions incorrectly #8755

yarusome opened this issue May 4, 2023 · 2 comments · Fixed by #8766
Labels
has PR Issues that already have a PR idle

Comments

@yarusome
Copy link
Contributor

yarusome commented May 4, 2023

Summary

Since mdn/content#14006:

  1. using this macro for CSS functions with parentheses in its parameter, e.g. {{CSSXref("abs()")}}, results in flaws, as parentheses are still kept in the URLs;
  2. :host() and fit-content() needs special-casing to append _function in the URLs.

Also:

  1. New page: overflow values content#26395 added <overflow>, which needs special-casing, too.
  2. The examples in cssxref.ejs need correction.

Proposed solution

On Line 53:

- // Deal with CSS functions by removing ()
- var slug = $0.replace(/&lt;(.*)&gt;/g, '$1');
+ // Deal with CSS data types and functions by removing <> and ()
+ var slug = $0.replace(/&lt;(.*)&gt;/g, "$1")
+     .replace(/\(\)/g, "");
  
- // Special case <color>, <flex>, and <position>
- switch ($0) {
-     case '&lt;color&gt;':
-         slug = 'color_value';
-         break;
- 
-     case '&lt;flex&gt;':
-         slug = 'flex_value';
-         break;
- 
-     case '&lt;position&gt;':
-         slug = 'position_value';
-         break;
- }
+ // Special case <color>, <flex>, <overflow>, and <position>
+ if (/^&lt;(color|flex|overflow|position)&gt;$/.test($0)) {
+     slug += "_value";
+ }
+ 
+ // Special case :host() and fit-content()
+ if (/^(:host|fit-content)\(\)$/.test($0)) {
+     slug += "_function";
+ }

URL

mdn/content#26575

Reproduction steps

Expected behavior

No flaw for {{CSSXref("url()")}}.

Actual behavior

A redirection flaw.

Device

Desktop

Browser

Firefox

Browser version

Stable

Operating system

Windows

Screenshot

No response

Anything else?

Relates to #8578.
Related discussion: https://github.com/orgs/mdn/discussions/369

Validations

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label May 4, 2023
@yarusome
Copy link
Contributor Author

yarusome commented May 4, 2023

@teoli2003 I hope the proposed solution here works for your case.

@teoli2003
Copy link
Member

Can you create a PR? (and avoid the var) Use let instead. [I really dislike these macros.]

@caugner caugner added has PR Issues that already have a PR and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels May 4, 2023
@github-actions github-actions bot added the idle label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Issues that already have a PR idle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants