message.js assumes status messages element has child element, incompatible default template

Created on 8 December 2023, almost 2 years ago

Problem/Motivation

Found in πŸ› Exceptions in batch no longer are shown on the page: Javascript error Fixed where we had to use olivero as the test them because the message.js does not work with the stark theme.

This is because core/modules/system/templates/status-messages.html.twig does not print anything under the top level div if there are no messages.

in core/misc/message.js we have

return wrapper.innerHTML === ''
        ? Drupal.Message.messageInternalWrapper(wrapper)
        : wrapper.firstElementChild;

But wrapper.innerHTML !== '' because there is return character. Any other character would also make it break. So in this case wrapper.firstElementChild will be NULL.

We could change the template but any contrib or custom template with this would also break.

Steps to reproduce

Proposed resolution

Check wrapper.childElementCount === 0 instead of wrapper.innerHTML === ''

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
JavascriptΒ  β†’

Last updated 8 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024