File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
packages/govuk-frontend/src/govuk/components/accordion Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ export class AccordionSection extends Component {
6262 } )
6363
6464 this . $toggle = createShowHideToggle ( this . $toggleIcon , this . $toggleText )
65+
66+ this . $heading = this . $root . querySelector (
67+ '.govuk-accordion__section-heading'
68+ )
69+
70+ if ( ! this . $heading ) {
71+ throw new ElementError ( {
72+ component : AccordionSection ,
73+ identifier : `Section heading (\`.govuk-accordion__section-heading\`)`
74+ } )
75+ }
6576 }
6677}
6778
Original file line number Diff line number Diff line change @@ -14,9 +14,6 @@ const sectionExpandedModifier = 'govuk-accordion__section--expanded'
1414/** @private */
1515const sectionButtonClass = 'govuk-accordion__section-button'
1616
17- /** @private */
18- const sectionHeadingClass = 'govuk-accordion__section-heading'
19-
2017/** @private */
2118const iconClass = 'govuk-accordion-nav__chevron'
2219
@@ -179,16 +176,8 @@ export class Accordion extends ConfigurableComponent {
179176 // before it gets moved to the `AccordionSection` class
180177 const $header = section . $header
181178
182- const $heading = $header . querySelector ( `.${ sectionHeadingClass } ` )
183179 const $summary = $header . querySelector ( `.${ sectionSummaryClass } ` )
184180
185- if ( ! $heading ) {
186- throw new ElementError ( {
187- component : Accordion ,
188- identifier : `Section heading (\`.${ sectionHeadingClass } \`)`
189- } )
190- }
191-
192181 // Create a button element that will replace the
193182 // '.govuk-accordion__section-button' span
194183 const $button = createElement ( 'button' , {
@@ -223,8 +212,8 @@ export class Accordion extends ConfigurableComponent {
223212
224213 $button . appendChild ( section . $toggle )
225214
226- $heading . removeChild ( section . $buttonPlaceholder )
227- $heading . appendChild ( $button )
215+ section . $heading . removeChild ( section . $buttonPlaceholder )
216+ section . $heading . appendChild ( $button )
228217 }
229218
230219 /**
You can’t perform that action at this time.
0 commit comments