Closed 36degrees closed 3 years ago
This is similar to #1808, and the solution is probably the same – wrapping the call with CSS.escape – although we should be able to use a simpler ID selector rather than using the attribute syntax:
this.$countMessage = $module.querySelector('#' + CSS.escape(this.$textarea.id) + '-info')
Based on #1843 fixing this, changing the label from 'Days' to 'Hours' as I think we have a solution that works that doesn't involve polyfilling CSS.escape
.
I think this might actually have been fixed by quoting the ID attribute which was done in #2080, except possibly if the ID itself contains double quotes?
Because we interpolate the textarea ID into a querySelector call without escaping it, the character count can fail if the ID contains characters that have a special meaning in CSS:
https://github.com/alphagov/govuk-frontend/blob/387c33d5280745523a9ee0fd1da961be584137e6/src/govuk/components/character-count/character-count.js#L8-L10