Problem/Motivation

There is a weird ternary condition in breadcrumb which can set an HTML attribute value as "null":

<a{{ item_attributes.addClass('fr-breadcrumb__link').setAttribute('href', url).setAttribute('aria-current', loop.last ? 'page' : null) }}

Once casted as string, this value will not be valid : https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attribut...

Proposed resolution

Replace by another condition:

{% set item_attributes = loop.last ? item_attributes.setAttribute('aria-current', 'page') : item_attributes %}
<a{{ item_attributes.addClass('fr-breadcrumb__link').setAttribute('href', url) }}>

Comments

pdureau created an issue. See original summary.

  • pdureau committed 0499e90c on 1.0.x
    Issue #3376773 by pdureau: Remove null attribute value in breadcrumb
    
pdureau’s picture

Title: [beta 4] Remove null attribuet value in breadcrumb. » [beta 4] Remove null attribute value in breadcrumb.
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.