alphagov / govuk_frontend_toolkit

❗️GOV.UK Frontend Toolkit is deprecated, and will only receive major bug fixes and security patches.
MIT License
403 stars 107 forks source link

show-hide-content throws an error for radio buttons with a period in their name attribute #402

Closed pauldwaite closed 5 years ago

pauldwaite commented 7 years ago

Steps to reproduce

  1. Use the show-hide-content.js script with a radio button that has a period in its name attribute, for example:

  2. Click on the radio button that shows the content.

Expected behaviour

The content is shown.

Actual behaviour

A JavaScript error is thrown:

Syntax error, unrecognized expression: [data-target] > input[type="radio"][name=choice.yesno][aria-controls]    jquery-1.11.3.js:1497

 Notes

The Scala Play framework’s form mapping feature allows form fields to be mapped to object properties, by putting periods in form field name attributes: https://www.playframework.com/documentation/2.5.x/ScalaForms#Nested-values

As such, it is common for Play web projects to have form fields with periods in their name attributes.

The HTML spec appears to allow name attributes containing periods: https://www.w3.org/TR/html5/forms.html#naming-form-controls:-the-name-attribute

36degrees commented 5 years ago

I believe this was addressed by #403 (just need to ship a release to actually get the change out)