Skip to content

Add nth_of_type selector helper to the stylesheet DSL#14

Merged
sbsoftware merged 3 commits intoreleases/v0.4.0from
feature/CSS-39
Feb 24, 2026
Merged

Add nth_of_type selector helper to the stylesheet DSL#14
sbsoftware merged 3 commits intoreleases/v0.4.0from
feature/CSS-39

Conversation

@sbsoftware-agent
Copy link
Copy Markdown
Collaborator

Summary

Add a nth_of_type(...) helper on CSS::Stylesheet so DSL users can build :nth-of-type(...) selectors without manually instantiating CSS::NthOfType.

Changes

  • Added CSS::Stylesheet.nth_of_type(...) overloads for:
  • Int32
  • String
  • CSS::NthOfType::Static (so symbols like :odd/:even map cleanly)
  • Updated selector DSL usage in specs to use the new helper:
  • rule div <= nth_of_type(:odd)
  • Added spec assertions verifying the helper emits CSS::NthOfType instances for numeric, string, and static values.

Validation

  • Ran: CRYSTAL_CACHE_DIR=/tmp/css-crystal-cache crystal spec
  • Result: 44 examples, 0 failures

Comment thread src/stylesheet.cr Outdated
Comment thread spec/selector_spec.cr Outdated
@sbsoftware sbsoftware merged commit c9254db into releases/v0.4.0 Feb 24, 2026
@sbsoftware sbsoftware deleted the feature/CSS-39 branch February 24, 2026 20:11
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