Skip to content

Commit fff5d22

Browse files
Always prefer return this in constructor early returns
This is a “just in case” commit where early ES2015 class implementations would return `undefined` in a subclass constructor (extended component) rather than the subclass instance Might only affect Safari 9 See: #2987 (comment)
1 parent 73b6983 commit fff5d22

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/govuk/components/character-count/character-count.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class CharacterCount {
116116
} else if ('maxlength' in this.config && this.config.maxlength) {
117117
this.maxLength = this.config.maxlength
118118
} else {
119-
return
119+
return this
120120
}
121121

122122
/** @private */

src/govuk/components/error-summary/error-summary.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export class ErrorSummary {
2121
// we need to safeguard against this so things keep
2222
// working the same now we read the elements data attributes
2323
if (!($module instanceof HTMLElement)) {
24-
// Little safety in case code gets ported as-is
25-
// into and ES2015 class constructor, where the return value matters
2624
return this
2725
}
2826

0 commit comments

Comments
 (0)