Govuk-frontend: Header component script is not compatible with govuk_template

Created on 10 Apr 2019  路  3Comments  路  Source: alphagov/govuk-frontend

Context

govuk_template has an IIFE for header navigation toggle which adds functionality to elements that have a .js-header-toggle class attached to it.

The header component in govuk-frontend uses the same .js-header-toggle class (applied to a button element) to toggle the header.

Problem

Because the govuk_template script is expecting an anchor instead of a button, it tries to get the href attribute and fails to do so if the header component from govuk-frontend is used.

Screen Shot 2019-04-10 at 15 37 29

Potential solution

Prefix or change js- classes to avoid clashed with other scripts (including the deprecated ones).

I'm happy to raise a PR myself since I think I introduced this bit of code, but I need a decision at the team level on what the solution should be.

馃悰 bug breaking change 馃晹 hours

All 3 comments

Adding this to the 3.0.0 milestone as a point of discussion, potentially we should be reviewing more than just this class and considering if they should be using a 'js-govuk' prefix.

We have decided to change our uses of 'js-' to be 'govuk-js-' as per @hannalaakso 's suggestion.

Should be fixed in v3.0.0. Closing this as #1444 has been merged.

Was this page helpful?
0 / 5 - 0 ratings