Server-rendered messages get their landmark from the Twig template. JavaScript messages use the same container. Clearing the JavaScript messages must not remove the server messages or the landmark that Twig owns. A container that already has an author-supplied role and name must not be renamed either.

Server landmark, JavaScript messages added

The container already has role="region" and aria-label="System messages" from the server, plus two server messages. The JavaScript messages go into a child wrapper; clearing them does not touch the container or its server messages.

Status message

Your changes have been saved.

JavaScript messages in the server container

2 server messages, 0 JavaScript messages. Landmark: present, server-owned.

Try it: add two JavaScript messages, then clear them. The two server messages stay, and the “System messages” landmark stays.

A name the author supplied

This container already has aria-label="Application notices". The merge request does not overwrite an existing role or name, and it removes only the values it assigned. A demonstration message can be added inside it; the author’s name is not replaced.

Status message

This message belongs to the application, not to Drupal’s system messages.

JavaScript messages in the author-named container

Landmark name: “Application notices” (author-owned; unchanged).

What to check

Why this matters

The merge request separates three owners: Twig owns the landmark on server-rendered messages; JavaScript owns one only when it added the role and name to a container that had none; and an author-supplied role or name belongs to that author. The page shows the first and third cases. Without this, clearing a JavaScript message could remove a landmark that the server still needs, or rename a container that another script owns.