alphagov/govuk_frontend_toolkit

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

pauldwaite opened this issue · 1 comments

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:

    Yes Yes
    Specify a meal type
  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

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