Cannot add attributes to the last element in the breadcrumbs
Bugs
What did you expect to happen?
Expect to be able to add custom attributes to the last element in a bread crumb. But the way the template has been written the attributes for the last element fall out side of the loop so it can not load the attributes into the tag.
Steps to reproduce it:
Add attributes to the breadcrumbs component inside the array
Check the last component, attributes are not added.
You can see below on line 13 to 15 this falls out of the loop, but the attributes are looking for item.attributes which cannot be accessed as it is outside of the loop.
File: node_modules/nhsuk-frontend/packages/components/breadcrumb/template.njk
04: <ol class="nhsuk-breadcrumb__list">
05: {%- for item in params.items %}
06: {%- if item.href %}
07: <li class="nhsuk-breadcrumb__item">
08: <a class="nhsuk-breadcrumb__link" href="{{ item.href }}"{% for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>{{ item.text }}</a>
09: {% if not loop.last %}{% endif %}
10: </li>
11: {%- endif -%}
12: {% endfor %}
13: <li class="nhsuk-breadcrumb__item">
14: <a class="nhsuk-breadcrumb__link" href="{{ params.href }}"{% for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>{{ params.text}}</a>
15: </li>
16: </ol>
What is the problem?
Cannot add attributes to the last element in the breadcrumbs
Bugs
What did you expect to happen?
Expect to be able to add custom attributes to the last element in a bread crumb. But the way the template has been written the attributes for the last element fall out side of the loop so it can not load the attributes into the tag.
Steps to reproduce it:
You can see below on line 13 to 15 this falls out of the loop, but the attributes are looking for item.attributes which cannot be accessed as it is outside of the loop.