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.
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.
Landmark name: “Application notices” (author-owned; unchanged).
What to check
- The first container keeps its landmark and its two server messages after the JavaScript messages are cleared. The count of server messages does not change.
- The second container keeps the name “Application notices”. It is never renamed to “System messages” and its role is not removed.
- Focus stays on the button you pressed in both examples.
- No live region is nested: the containers are regions, and only the individual messages have
role="status"orrole="alert". - This is a simplified model of the ownership rule. The MR tracks the values it assigned in a
WeakMap; this page does not modify the containers at all.
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.