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

feat(css/parser): normalize and improve function name #6667

Merged

Conversation

alexander-akait
Copy link
Collaborator

Description:

Improve function name:

  1. Normalize name (lowercase)
  2. Use dashed ident (we use the same for at-rules/declarations)

From spec (https://www.w3.org/TR/css-values-4/#dashed-idents):

CSS will use more in the future, as more author-controlled syntax is added. CSS authoring tools, such as preprocessors that turn custom syntax into standard CSS, should use as well, to avoid clashing with future CSS design.
For example, if a CSS preprocessor added a new "custom" at-rule, it shouldn’t spell it @Custom, as this would clash with a future official @Custom rule added by CSS. Instead, it should use @--custom, which is guaranteed to never clash with anything defined by CSS.

  1. use js_word!()

BREAKING CHANGE:

Yes

Related issue (if exists):

No

@alexander-akait alexander-akait force-pushed the feat-improve-and-normalize-function-name branch from 0245890 to 8f480fd Compare December 15, 2022 21:38
@kdy1 kdy1 added this to the Planned milestone Dec 15, 2022
@kdy1 kdy1 self-assigned this Dec 15, 2022
@alexander-akait alexander-akait marked this pull request as ready for review December 16, 2022 00:16
@alexander-akait alexander-akait force-pushed the feat-improve-and-normalize-function-name branch from 67920dd to b2cda90 Compare December 18, 2022 22:34
@alexander-akait
Copy link
Collaborator Author

Rebased

@@ -100,12 +101,39 @@ impl Take for SimpleBlock {
}
}

#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
pub enum FunctionName {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kdy1 Yeah, it reduce code, we have the same for AtRule and Declaration, so we will have less code

@alexander-akait alexander-akait force-pushed the feat-improve-and-normalize-function-name branch from 4087178 to 60c7bf4 Compare December 19, 2022 15:31
@alexander-akait
Copy link
Collaborator Author

@kdy1 Rebased 👍

@alexander-akait alexander-akait force-pushed the feat-improve-and-normalize-function-name branch from 60c7bf4 to 90fd03b Compare December 20, 2022 10:50
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

swc-bump:

  • swc_css_ast --breaking

@kdy1 kdy1 enabled auto-merge (squash) December 20, 2022 11:48
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit 2571070 into swc-project:main Dec 20, 2022
@alexander-akait alexander-akait deleted the feat-improve-and-normalize-function-name branch December 20, 2022 15:08
@kdy1 kdy1 modified the milestones: Planned, 1.3.24 Dec 21, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants