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): improve selector AST #6112

Merged
merged 3 commits into from Oct 12, 2022

Conversation

alexander-akait
Copy link
Collaborator

Description:

Resolve TODO + tests + improve AST

BREAKING CHANGE:

Yes

Related issue (if exists):

No

@@ -1 +1 @@
:root{--fg-color:blue;--fg-\color-other:blue}.box{background-color:rebeccapurple;background-color:var(--fg-color);border-radius:10px;width:100px;height:100px}.box:hover{animation-name:rotate\ rotate;animation-duration:.7s}@keyframes rotate\ rotate{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes rotate{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes rotat\e{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}*|*{color:blue}*|*{color:blue}@media screen and (min-width:0\0){body{color:red}}body{margin:-\1px}
:root{--fg-color:blue;--fg-\color-other:blue}.box{background-color:rebeccapurple;background-color:var(--fg-color);border-radius:10px;width:100px;height:100px}.box:hover{animation-name:rotate\ rotate;animation-duration:.7s}@keyframes rotate\ rotate{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes rotate{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes rotat\e{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}*|*{color:blue}\*|*{color:blue}@media screen and (min-width:0\0){body{color:red}}body{margin:-\1px}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Original code:

\*|*{color:blue}

According spec it is \* namespace (so we print it as ident).

Chrome has bug here \*|*{color:blue} parsed as *{color:blue}, firefox doesn't affected this bug and just can't parse it.

And both wrong here, chrome should not parse this as any namespace, firefox should parse this with \* namespace 😄 I will report this in both browsers

@kdy1 kdy1 self-assigned this Oct 11, 2022
@kdy1 kdy1 added this to the Planned milestone Oct 11, 2022
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.

There's a merge conflict

@alexander-akait
Copy link
Collaborator Author

@kdy1 Yeah, I will fix it soon

@alexander-akait
Copy link
Collaborator Author

@kdy1 Rebased 👍

@kdy1
Copy link
Member

kdy1 commented Oct 12, 2022

Is this necessary? I think this may make working with AST harder

@alexander-akait
Copy link
Collaborator Author

@kdy1 Yep, * is not the Ident, it is the special thing (any namespace), anyway it should simplify using AST for manipulation, because now you can easy to catch all Any namespace (minify purposes and svg minification), but namespace is not popular in current CSS, also here a small perf improvement too

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) October 12, 2022 02:26
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 c765f0f into swc-project:main Oct 12, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.7 Oct 12, 2022
@alexander-akait alexander-akait deleted the fix-selector-ast branch October 12, 2022 16:08
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 12, 2022
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