The js-accordion__header class starts on the <hx> element but when JavaScript takes over the element is given js-accordion__title and the child <button> is given js-accordion__header. E.g:
I require both non/javascript versions to have the same style so I applied custom-accordion__header to my source HTML. This causes style problems because custom-accordion__header ends up being nested inside itself. Like so:
The element is given
js-accordion__header
class starts on the<hx>
element but when JavaScript takes over thejs-accordion__title
and the child<button>
is givenjs-accordion__header
. E.g:Becomes
I require both non/javascript versions to have the same style so I applied
custom-accordion__header
to my source HTML. This causes style problems becausecustom-accordion__header
ends up being nested inside itself. Like so:I did try changing the classes generated with:
This solved the style problem, but broke the toggle functionality. The following was logged to the console.
In the end, I have had to drop the use of custom prefixes and only use js-accordion__xxx which isn't the end of the world.
Possible solution to this problem Have the heading element keep
js_accordion__header
and the generated button be given a class ofjs-accordion__button