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

additional CSS selector formatting #59

Merged

Conversation

flavorjones
Copy link
Collaborator

@flavorjones flavorjones commented Jun 4, 2024

Implement CSS selector formatting for IdSelector, HashToken, PseudoClassSelector, and PseudoElementSelector, and add test coverage.

Also backfill coverage of the existing PseudoElementSelector AST.

@flavorjones flavorjones force-pushed the flavorjones-selector-formatting branch from c711ae3 to 5d8fe83 Compare June 4, 2024 18:03
@flavorjones flavorjones marked this pull request as draft June 4, 2024 18:03
@flavorjones flavorjones force-pushed the flavorjones-selector-formatting branch from 5d8fe83 to c152737 Compare June 4, 2024 18:26
@flavorjones flavorjones marked this pull request as ready for review June 4, 2024 18:28
@@ -125,7 +125,7 @@ def accept(visitor)
end

def child_nodes
[type, subclasses, pseudo_elements].flatten
[type, subclasses, pseudo_elements].compact.flatten
Copy link
Member

Choose a reason for hiding this comment

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

Up to you, but you could make this:

Suggested change
[type, subclasses, pseudo_elements].compact.flatten
[type, *subclasses, *pseudo_elements]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately that change doesn't account for a) type being nil and needing to be removed, and b) pseudo_elements contains nested arrays.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While we're here, I don't really like the fact that pseudo_elements contains nested arrays (see the test "parses a compound selector with pseudo-elements and pseudo-classes" to see what it looks like), but regardless I think child_nodes should flatten it all.

@flavorjones
Copy link
Collaborator Author

@kddnewton If this is OK with you, would you mind merging? I've got more work that's based on this branch. ❤️

@kddnewton kddnewton merged commit 57a45cb into ruby-syntax-tree:main Jun 5, 2024
2 checks passed
@flavorjones flavorjones deleted the flavorjones-selector-formatting branch June 5, 2024 17:16
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