diff --git a/spec/selector_spec.cr b/spec/selector_spec.cr index 18109b1..e6d9e14 100644 --- a/spec/selector_spec.cr +++ b/spec/selector_spec.cr @@ -74,7 +74,7 @@ module CSS::SelectorSpec display :none end - rule div <= CSS::NthOfType.new(:odd) do + rule div <= nth_of_type(:odd) do display :none end diff --git a/src/stylesheet.cr b/src/stylesheet.cr index 5dad1ca..d0708aa 100644 --- a/src/stylesheet.cr +++ b/src/stylesheet.cr @@ -28,6 +28,10 @@ module CSS CSS::CalcFunctionCall.new(calculation) end + def self.nth_of_type(exp : Int32 | String | CSS::NthOfType::Static) + CSS::NthOfType.new(exp) + end + # Type-safe helper for length/percentage `clamp()` values. # # Note: this helper enforces units for non-zero number literals (same as property setters).