File tree Expand file tree Collapse file tree
packages/govuk-frontend/src/govuk/components/character-count Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,7 +131,10 @@ export class CharacterCount extends ConfigurableComponent {
131131 locale : closestAttributeValue ( this . $root , 'lang' )
132132 } )
133133
134- if ( this . config . countType === 'characters' ) {
134+ if (
135+ this . config . countType === 'characters' ||
136+ ( this . config . countType === 'words' && this . config . maxwords === undefined )
137+ ) {
135138 if ( ! ( 'Segmenter' in Intl ) ) {
136139 throw new SupportError (
137140 formatErrorMessage (
@@ -142,7 +145,7 @@ export class CharacterCount extends ConfigurableComponent {
142145 }
143146
144147 this . segmenter = new Intl . Segmenter ( this . i18n . locale , {
145- granularity : 'grapheme'
148+ granularity : this . config . countType === 'words' ? 'word' : 'grapheme'
146149 } )
147150 }
148151
You can’t perform that action at this time.
0 commit comments