Change record status: 
Project: 
Introduced in branch: 
8.7.x
Introduced in version: 
8.7.0
Description: 

See also https://www.drupal.org/node/2930536.

To support the new JavaScript Message API, the status_messages render element now supports an optional #include_fallback property. This property defaults to FALSE, but if set to TRUE, an empty DIV with a special data attribute will be rendered alongside any available status messages, providing a container element the JavaScript Message API can add messages to.

Example

Without the fallback area:
$element = ['#type' => 'status_messages'] will, when rendered, produce output like this: <div class="messages"><ul><li>My status message</li></ul></div>

With the fallback area:
$element = ['#type' => 'status_messages', '#include_fallback' => TRUE] will produce rendered output like this: <div data-drupal-messages-fallback class="hidden"></div><div class="messages"><ul><li>Yet another status message</li></ul></div>

Under most circumstances, you should not need to use the #include_fallback property, because the fallback area is rendered on all pages by default. However, if your code provides display variant plugins, you may wish to use the #include_fallback property if your variant(s) are using status_messages elements, as this will ensure that the JavaScript Message API always has a container element to work with, even if there are no status messages to display. See core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php for an example.

Impacts: 
Module developers