The merge request does not create a separate landmark element. It adds role="region" and aria-label to the existing [data-drupal-messages] container when a message is present, and removes them when the last message goes. This page models that lifecycle on one persistent container.
The container below is in the DOM from the start. Its identity never changes. This is a stand-in for the default container, not Drupal.Message; the attribute lifecycle matches, the code does not.
No messages. The container has no landmark attributes.
Expected states
| Action | Expected landmark behaviour |
|---|---|
| Initial empty container | No landmark: no role, no name. |
| Add the first message | The container becomes a region named “System messages”. |
| Add more messages | The same region remains; the messages are inside it. |
| Remove one message | The region remains while any message is left. |
| Remove the final message | The landmark attributes are removed; the empty container stays. |
| Add another message | The attributes are restored on the same container. |
What to check
- In DevTools, watch the one
#message-containerelement. It is never replaced;roleandaria-labelare added to and removed from it. - Before the first message, the landmarks list has no “System messages”. After it, it has one.
- Additional messages stay inside the same region; the count stays at one.
- Keyboard focus stays on the button you pressed. It is never moved into the messages.
- Each message keeps its own live role:
statusfor the confirmation,alertfor the warning and the error. The container is never a live region, so there are no nested live regions. - The container becoming a landmark does not announce anything. Any announcement comes from the message’s own role, as it does today.
How this corresponds to the merge request
- Only the default
[data-drupal-messages]container is changed. A wrapper a caller supplies is left alone. - The MR records the role and name it assigned in a
WeakMapand removes them only if they still match. If another script changes them, Drupal leaves the landmark alone. - Detection uses
[data-drupal-message-id]or a non-empty.messagesgroup. An empty group is not a message. - Focus and
Drupal.announce()are untouched. The landmark is navigation, not an announcement. - This page keeps the container’s attributes in a simple marker (
data-demo-owned) instead of aWeakMap. The mixed page shows the server-owned and author-named cases.