Skip to content

Commit 3c72601

Browse files
authored
Fix mix with string keys ending in ! (#967)
Closes #963
2 parents a6ec9fe + 3132647 commit 3c72601

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/phlex/helpers.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ module Phlex::Helpers
3636
end
3737

3838
result.transform_keys! do |key|
39-
key.end_with?("!") ? key.name.chop.to_sym : key
39+
case key
40+
when Symbol
41+
key.end_with?("!") ? key.name.chop.to_sym : key
42+
when String
43+
key.end_with?("!") ? key.chop.to_sym : key
44+
else
45+
key
46+
end
4047
end
4148
end
4249
end

quickdraw/helpers/mix.test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@
6565
assert_equal output, { class: ["foo", "bar"] }
6666
end
6767

68-
test "override" do
68+
test "override with symbol key" do
6969
output = mix({ class: "foo" }, { class!: "bar" })
7070
assert_equal output, { class: "bar" }
7171
end
7272

73+
test "override with string key" do
74+
output = mix({ class: "foo" }, { "class!" => "bar" })
75+
assert_equal output, { class: "bar" }
76+
end
77+
7378
test "set + set" do
7479
output = mix({ class: Set["foo"] }, { class: Set["bar"] })
7580
assert_equal output, { class: Set["foo", "bar"] }

0 commit comments

Comments
 (0)