sdr_view_components 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da67f1cfd2cfb8a85d88d496df552d11e6a5c0648ae0662d4847ee6735aedf04
4
- data.tar.gz: cf355351c20972ad34829bd2565e5363f10bd3b443befdc879ad008dea30ed4a
3
+ metadata.gz: 9dbc7e428976b883ea16efc5d7f520859d1f91339da3e8c4c1972f058f048309
4
+ data.tar.gz: 3d28e043fc28c28001b6e1de79728b4e81204fb092ccc04cbed2e4b302c9b9b7
5
5
  SHA512:
6
- metadata.gz: e2d8ad78b5a7de81672e11e55d0d2a5ce524075ed2317f6917d1b02ed9fb97c64129cb428a74e152fc1cb4ce46cf37c19663a29e03fdf87aed78310aa8a8c2c1
7
- data.tar.gz: e947cae010e6f7d039952b66ab9875609ba19dcd8ccabf0fa8d1aca0eba2f1f6109d44480ea2949136cc7c6fd6b6ad8f84866b4d03879f7951abf129c6ab4ab8
6
+ metadata.gz: f02a18b3d5a33250fb4bac47934887e85a5449c1c8fabb6bd02ef6c3111d37a88cdf93229238157d0eefffb6c9039f778ee039ac0853e21b57412243c5844d0d
7
+ data.tar.gz: 350cfee1326d362535d60fd2d8d07ab14370b60d9ce36204e38e1532919024e62a77f1af43ed258581285fae4bcb068666633e8c80648020d0738dc4b31552e7
@@ -15,14 +15,22 @@ module SdrViewComponents
15
15
  end
16
16
 
17
17
  def label_field_name
18
- "#{sanitize(field_name)}_#{sanitize(input_args[:value])}"
18
+ "#{sanitize_method_name(field_name)}_#{sanitize_value(input_args[:value])}"
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- # From https://github.com/rails/rails/blob/main/actionview/lib/action_view/helpers/form_tag_helper.rb
24
- def sanitize(value)
25
- value.to_s.delete(']').tr('^-a-zA-Z0-9:.', '_')
23
+ # The input is rendered by form.radio_button, so the label's for must match the id that
24
+ # ActionView::Helpers::Tags::Base generates. These mirror its sanitized_method_name and
25
+ # sanitized_value. Note this is *not* form_tag_helper.rb's sanitize_to_id, which applies
26
+ # to radio_button_tag and disagrees on uppercase letters, '.', and other non-word chars.
27
+ # From https://github.com/rails/rails/blob/main/actionview/lib/action_view/helpers/tags/base.rb
28
+ def sanitize_method_name(name)
29
+ name.to_s.delete_suffix('?')
30
+ end
31
+
32
+ def sanitize_value(value)
33
+ value.to_s.gsub(/[\s.]/, '_').gsub(/[^-[[:word:]]]/, '').downcase
26
34
  end
27
35
  end
28
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.11.1'
4
+ VERSION = '0.11.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
377
  requirements: []
378
- rubygems_version: 4.0.16
378
+ rubygems_version: 4.0.6
379
379
  specification_version: 4
380
380
  summary: Rails gem for providing SDR-specific ViewComponents.
381
381
  test_files: []