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

We need to escape other characters #458

Closed nubz closed 6 years ago

nubz commented 6 years ago

https://github.com/alphagov/govuk_frontend_toolkit/blob/c88df4977fbb1d63950e8d19cc7dfbd02ede0709/javascripts/govuk/show-hide-content.js#L18

In a service I am working on, a back-end (Scala Play) naming convention for grouped elements uses a period (.) in field names e.g. contactAddress.line1

The existing showHideContent escapeElementName() method does not handle this and we see the module failing when invoked with errors due to the presence of periods. The use of periods in field names is valid HTML so we are working with a solution to expand the characters escaped. What we found was using CSS.escape() with a polyfil for unsupported browsers works well for us. Is this something being worked on or should I propose a PR?

NickColley commented 6 years ago

Hey! We're currently rebuilding this for the new GOV.UK Frontend project, but that's in private beta for now.

Feel free to propose a PR, but the minimum might be to give us an example code snippet we can use to make sure the new version covers this use case.

36degrees commented 6 years ago

Thanks for raising, @nubz.

I believe this is a duplicate of #402, so I'm going to close this. (I also think it would be fixed by #403)