Skip to content

Commit

Permalink
PR changes: expander JS replace all
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Dec 12, 2023
1 parent 98ba043 commit 8bf9425
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; // if this ; is omitted, none
try {
buttonAttributes = JSON.parse(buttonAttributes)
for (var rawKey in buttonAttributes) {
var key = rawKey.replace(/_/i, '-').toLowerCase()
var key = rawKey.replace(/_/g, '-').toLowerCase()
var rawValue = buttonAttributes[rawKey]
var value = typeof rawValue === 'object' ? JSON.stringify(rawValue) : rawValue
$button.setAttribute('data-' + key, value)
Expand Down
3 changes: 2 additions & 1 deletion spec/javascripts/components/expander-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ describe('An expander module', function () {
ga4_expandable: '',
ga4_event: {
event_name: 'select_content',
type: 'finder'
type: 'finder',
test_attribute_with_many_underscores: 'oh yes'
}
}

Expand Down

0 comments on commit 8bf9425

Please sign in to comment.