diff --git a/CHANGELOG.md b/CHANGELOG.md index e5437c43ab..6e82a2d8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## main +* Fix bug when empty string was passed to Classify. + + *Manuel Puyol* + ## 0.0.19 * Add support for functional colors to `color` system argument. diff --git a/lib/primer/classify.rb b/lib/primer/classify.rb index 884fc1ddd2..054355d7cb 100644 --- a/lib/primer/classify.rb +++ b/lib/primer/classify.rb @@ -182,7 +182,7 @@ def extract_hash(styles_hash) end def extract_value(memo, key, val, breakpoint) - return if val.nil? + return if val.nil? || val == "" if SPACING_KEYS.include?(key) if MARGIN_DIRECTION_KEYS.include?(key) diff --git a/test/primer/classify_test.rb b/test/primer/classify_test.rb index 34961f0065..75b77e7604 100644 --- a/test/primer/classify_test.rb +++ b/test/primer/classify_test.rb @@ -118,6 +118,7 @@ def test_underline end def test_color + assert_generated_class(nil, { color: "" }) assert_generated_class("text-blue", { color: :blue }) assert_generated_class("text-red", { color: :red }) assert_generated_class("text-gray-light", { color: :gray_light })