Using class attribute throws type error
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3552026. -->
Reported by: [wotnak](https://www.drupal.org/user/3558113)
Related to !23
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Related to attributes support introduced in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/linked_field/-/work_items/3313062" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/linked_field/-/work_items/3313062</a></span>.</p>
<p>When using the class attribute, following error is thrown:</p>
<pre>TypeError: html_entity_decode(): Argument #1 ($string) must be of type string, array given w html_entity_decode() (linia 398 w /var/www/drupal/web/core/lib/Drupal/Component/Utility/Html.php).<br><br>#0 /var/www/drupal/web/core/lib/Drupal/Component/Utility/Html.php(398): html_entity_decode()<br>#1 /var/www/drupal/web/modules/contrib/linked_field/src/LinkedFieldManager.php(267): Drupal\Component\Utility\Html::decodeEntities()<br>...</pre><p>In code added in <a href="https://git.drupalcode.org/project/linked_field/-/commit/3ff6a32072c7742b26c4bc43300df778baa0610d">https://git.drupalcode.org/project/linked_field/-/commit/3ff6a32072c7742b26c4bc43300df778baa0610d</a> class attributes are stringified before decoding HTML entities, but this step was added only in the code path for img/picture HTML elements. When the class attribute is used on another element the error is thrown.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Stringify class attribute before further processing also for html elements other than img/picture.</p>
issue