Commit a287113e authored by alexpott's avatar alexpott

Issue #2187113 by Cottser, joelpittet: Incorrect usage of attributes in twig...

Issue #2187113 by Cottser, joelpittet: Incorrect usage of attributes in twig templates resulting in possible duplicate attributes
parent 944d3dab
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
*/ */
#} #}
{% set heading_id = attributes.id ~ '-menu'|clean_id %} {% set heading_id = attributes.id ~ '-menu'|clean_id %}
<nav{{ attributes }} role="navigation" aria-labelledby="{{ heading_id }}"> <nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes|without('role', 'aria-labelledby') }}>
{# Label. If not displayed, we still provide it for screen readers. #} {# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %} {% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %} {% set title_attributes = title_attributes.addClass('visually-hidden') %}
......
...@@ -15,4 +15,4 @@ ...@@ -15,4 +15,4 @@
* @ingroup themeable * @ingroup themeable
*/ */
#} #}
<a href="{{ url }}"{{ attributes.addClass('feed-icon') }}>{{ icon }}</a> <a href="{{ url }}"{{ attributes.addClass('feed-icon')|without('href') }}>{{ icon }}</a>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
{# Print first item if we are not on the first page. #} {# Print first item if we are not on the first page. #}
{% if items.first %} {% if items.first %}
<li class="pager__item pager__item--first"> <li class="pager__item pager__item--first">
<a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes }}> <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }}>
<span class="visually-hidden">{{ 'First page'|t }}</span> <span class="visually-hidden">{{ 'First page'|t }}</span>
<span aria-hidden="true">{{ items.first.text|default('« first'|t) }}</span> <span aria-hidden="true">{{ items.first.text|default('« first'|t) }}</span>
</a> </a>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
{# Print previous item if we are not on the first page. #} {# Print previous item if we are not on the first page. #}
{% if items.previous %} {% if items.previous %}
<li class="pager__item pager__item--previous"> <li class="pager__item pager__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes }}> <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span> <span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹ previous'|t) }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹ previous'|t) }}</span>
</a> </a>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
{% else %} {% else %}
{% set title = 'Go to page @key'|t({'@key': key}) %} {% set title = 'Go to page @key'|t({'@key': key}) %}
{% endif %} {% endif %}
<a href="{{ item.href }}" title="{{ title }}"{{ item.attributes }}> <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }}>
<span class="visually-hidden"> <span class="visually-hidden">
{{ current == key ? 'Current page'|t : 'Page'|t }} {{ current == key ? 'Current page'|t : 'Page'|t }}
</span> </span>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
{# Print next item if we are not on the last page. #} {# Print next item if we are not on the last page. #}
{% if items.next %} {% if items.next %}
<li class="pager__item pager__item--next"> <li class="pager__item pager__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes }}> <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span> <span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('next ›'|t) }}</span> <span aria-hidden="true">{{ items.next.text|default('next ›'|t) }}</span>
</a> </a>
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
{# Print last item if we are not on the last page. #} {# Print last item if we are not on the last page. #}
{% if items.last %} {% if items.last %}
<li class="pager__item pager__item--last"> <li class="pager__item pager__item--last">
<a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes }}> <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }}>
<span class="visually-hidden">{{ 'Last page'|t }}</span> <span class="visually-hidden">{{ 'Last page'|t }}</span>
<span aria-hidden="true">{{ items.last.text|default('last »'|t) }}</span> <span aria-hidden="true">{{ items.last.text|default('last »'|t) }}</span>
</a> </a>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
*/ */
#} #}
{% for type, messages in message_list %} {% for type, messages in message_list %}
<div class="{{ attributes.class }}" role="contentinfo" aria-label="{{ status_headings[type] }}"> <div role="contentinfo" aria-label="{{ status_headings[type] }}"{{ attributes|without('role', 'aria-label') }}>
{% if type == 'error' %} {% if type == 'error' %}
<div role="alert"> <div role="alert">
{% endif %} {% endif %}
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
* @ingroup themeable * @ingroup themeable
*/ */
#} #}
<div data-vertical-tabs-panes{{ attributes }}>{{ children }}</div> <div{{ attributes.setAttribute('data-vertical-tabs-panes', TRUE) }}>{{ children }}</div>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<ul class="pager__items"> <ul class="pager__items">
{% if items.previous %} {% if items.previous %}
<li class="pager__item pager__item--previous"> <li class="pager__item pager__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes }}> <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span> <span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
</a> </a>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
{% endif %} {% endif %}
{% if items.next %} {% if items.next %}
<li class="pager__item pager__item--next"> <li class="pager__item pager__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes }}> <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span> <span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span> <span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
</a> </a>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
{% if row.separator -%} {% if row.separator -%}
{{ row.separator }} {{ row.separator }}
{%- endif %} {%- endif %}
<a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active') }}>{{ row.link }}</a> <a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active')|without('href') }}>{{ row.link }}</a>
{% if options.count %} {% if options.count %}
({{ row.count }}) ({{ row.count }})
{% endif %} {% endif %}
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<div class="item-list"> <div class="item-list">
<ul class="views-summary"> <ul class="views-summary">
{% for row in rows %} {% for row in rows %}
<li><a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active') }}>{{ row.link }}</a> <li><a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active')|without('href') }}>{{ row.link }}</a>
{% if options.count %} {% if options.count %}
({{ row.count }}) ({{ row.count }})
{% endif %} {% endif %}
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
] ]
%} %}
{% endif %} {% endif %}
<th{{ column.attributes.addClass(column_classes) }} scope="col"> <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
{{ column.content }} {{ column.content }}
</th> </th>
{% endfor %} {% endfor %}
......
...@@ -47,13 +47,13 @@ ...@@ -47,13 +47,13 @@
] ]
%} %}
{% set heading_id = attributes.id ~ '-menu'|clean_id %} {% set heading_id = attributes.id ~ '-menu'|clean_id %}
<nav{{ attributes.addClass(classes) }} role="navigation" aria-labelledby="{{ heading_id }}"> <nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
{# Label. If not displayed, we still provide it for screen readers. #} {# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %} {% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %} {% set title_attributes = title_attributes.addClass('visually-hidden') %}
{% endif %} {% endif %}
{{ title_prefix }} {{ title_prefix }}
<h2 id="{{ heading_id }}"{{ title_attributes }}>{{ configuration.label }}</h2> <h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
{{ title_suffix }} {{ title_suffix }}
{# Menu. #} {# Menu. #}
......
...@@ -57,13 +57,13 @@ ...@@ -57,13 +57,13 @@
*/ */
#} #}
{{ title_prefix }} {{ title_prefix }}
<h3 class="title"{{ title_attributes }}> <h3{{ title_attributes.addClass('title') }}>
<a href="{{ url }}">{{ title }}</a> <a href="{{ url }}">{{ title }}</a>
</h3> </h3>
{{ title_suffix }} {{ title_suffix }}
<div class="search-snippet-info"> <div class="search-snippet-info">
{% if snippet %} {% if snippet %}
<p class="search-snippet"{{ content_attributes }}>{{ snippet }}</p> <p{{ content_attributes.addClass('search-snippet') }}>{{ snippet }}</p>
{% endif %} {% endif %}
{% if info %} {% if info %}
<p class="search-info">{{ info }}</p> <p class="search-info">{{ info }}</p>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
'vocabulary-' ~ term.bundle|clean_class, 'vocabulary-' ~ term.bundle|clean_class,
] ]
%} %}
<div id="taxonomy-term-{{ term.id }}"{{ attributes.addClass(classes)|without('id') }}> <div{{ attributes.setAttribute('id', 'taxonomy-term-' ~ term.id).addClass(classes) }}>
{{ title_prefix }} {{ title_prefix }}
{% if not page %} {% if not page %}
<h2><a href="{{ url }}">{{ name }}</a></h2> <h2><a href="{{ url }}">{{ name }}</a></h2>
......
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
* @see template_preprocess_feed_icon() * @see template_preprocess_feed_icon()
*/ */
#} #}
<a href="{{ url }}"{{ attributes.addClass('feed-icon') }}>{{ icon }}</a> <a href="{{ url }}"{{ attributes.addClass('feed-icon')|without('href') }}>{{ icon }}</a>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
'messages--' ~ type, 'messages--' ~ type,
] ]
%} %}
<div class="{{ attributes.addClass(classes).class }}" role="contentinfo" aria-label="{{ status_headings[type] }}"> <div role="contentinfo" aria-label="{{ status_headings[type] }}"{{ attributes.addClass(classes)|without('role', 'aria-label') }}>
{% if type == 'error' %} {% if type == 'error' %}
<div role="alert"> <div role="alert">
{% endif %} {% endif %}
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
{# Print first item if we are not on the first page. #} {# Print first item if we are not on the first page. #}
{% if items.first %} {% if items.first %}
<li class="pager__item pager__item--first"> <li class="pager__item pager__item--first">
<a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes }}> <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }}>
<span class="visually-hidden">{{ 'First page'|t }}</span> <span class="visually-hidden">{{ 'First page'|t }}</span>
<span aria-hidden="true">{{ items.first.text|default('« first'|t) }}</span> <span aria-hidden="true">{{ items.first.text|default('« first'|t) }}</span>
</a> </a>
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
{# Print previous item if we are not on the first page. #} {# Print previous item if we are not on the first page. #}
{% if items.previous %} {% if items.previous %}
<li class="pager__item pager__item--previous"> <li class="pager__item pager__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes }}> <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span> <span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹ previous'|t) }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹ previous'|t) }}</span>
</a> </a>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
{% else %} {% else %}
{% set title = 'Go to page @key'|t({'@key': key}) %} {% set title = 'Go to page @key'|t({'@key': key}) %}
{% endif %} {% endif %}
<a href="{{ item.href }}" title="{{ title }}"{{ item.attributes }}> <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }}>
<span class="visually-hidden"> <span class="visually-hidden">
{{ current == key ? 'Current page'|t : 'Page'|t }} {{ current == key ? 'Current page'|t : 'Page'|t }}
</span> </span>
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
{# Print next item if we are not on the last page. #} {# Print next item if we are not on the last page. #}
{% if items.next %} {% if items.next %}
<li class="pager__item pager__item--next"> <li class="pager__item pager__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes }}> <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span> <span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('next ›'|t) }}</span> <span aria-hidden="true">{{ items.next.text|default('next ›'|t) }}</span>
</a> </a>
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
{# Print last item if we are not on the last page. #} {# Print last item if we are not on the last page. #}
{% if items.last %} {% if items.last %}
<li class="pager__item pager__item--last"> <li class="pager__item pager__item--last">
<a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes }}> <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }}>
<span class="visually-hidden">{{ 'Last page'|t }}</span> <span class="visually-hidden">{{ 'Last page'|t }}</span>
<span aria-hidden="true">{{ items.last.text|default('last »'|t) }}</span> <span aria-hidden="true">{{ items.last.text|default('last »'|t) }}</span>
</a> </a>
......
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
* @see template_preprocess_vertical_tabs() * @see template_preprocess_vertical_tabs()
*/ */
#} #}
<div data-vertical-tabs-panes{{ attributes }}>{{ children }}</div> <div{{ attributes.setAttribute('data-vertical-tabs-panes', TRUE) }}>{{ children }}</div>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ul class="pager__items"> <ul class="pager__items">
{% if items.previous %} {% if items.previous %}
<li class="pager__item pager__item--previous"> <li class="pager__item pager__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes }}> <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span> <span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
</a> </a>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
{% endif %} {% endif %}
{% if items.next %} {% if items.next %}
<li class="pager__item pager__item--next"> <li class="pager__item pager__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes }}> <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span> <span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span> <span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
</a> </a>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{% if row.separator -%} {% if row.separator -%}
{{ row.separator }} {{ row.separator }}
{%- endif %} {%- endif %}
<a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active') }}>{{ row.link }}</a> <a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active')|without('href') }}>{{ row.link }}</a>
{% if options.count %} {% if options.count %}
({{ row.count }}) ({{ row.count }})
{% endif %} {% endif %}
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div class="item-list"> <div class="item-list">
<ul class="views-summary"> <ul class="views-summary">
{% for row in rows %} {% for row in rows %}
<li><a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active') }}>{{ row.link }}</a> <li><a href="{{ row.url }}"{{ row.attributes.addClass(row.active ? 'is-active')|without('href') }}>{{ row.link }}</a>
{% if options.count %} {% if options.count %}
({{ row.count }}) ({{ row.count }})
{% endif %} {% endif %}
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
] ]
%} %}
{% endif %} {% endif %}
<th{{ column.attributes.addClass(column_classes) }} scope="col"> <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
{{ column.content }} {{ column.content }}
</th> </th>
{% endfor %} {% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment