Skip to content

Commit 3c6bcd4

Browse files
committed
Add DOM#id suffix spec, use dom.id() in README examples
Missing spec coverage for the suffixes parameter on DOM#id. README examples were manually interpolating ids instead of using the API.
1 parent 6a0d1ea commit 3c6bcd4

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class SignupForm < Components::Form
412412
fieldset do
413413
legend { "Roles" }
414414
Role.all.each do |role|
415-
label(for: "#{field(:role_ids).dom.id}_#{role.id}") do
415+
label(for: field(:role_ids).dom.id(role.id)) do
416416
Field(:role_ids).checkbox(value: role.id)
417417
whitespace
418418
plain role.name
@@ -426,7 +426,7 @@ class SignupForm < Components::Form
426426
fieldset do
427427
legend { "Plan" }
428428
Plan.all.each do |plan|
429-
label(for: "#{field(:plan_id).dom.id}_#{plan.id}") do
429+
label(for: field(:plan_id).dom.id(plan.id)) do
430430
Field(:plan_id).radio(plan.id)
431431
whitespace
432432
plain plan.name

spec/superform/dom_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@ def build_lineage(**lineage)
7272

7373
expect(field.dom.id).to eq("grandparent_bars_baz")
7474
end
75+
76+
it "appends suffixes to the id" do
77+
field = build_lineage(parent: Superform::Namespace, child: Superform::Field)
78+
expect(field.dom.id("male")).to eq("parent_child_male")
79+
expect(field.dom.id(1)).to eq("parent_child_1")
80+
end
7581
end
7682
end

0 commit comments

Comments
 (0)