views – Twig sets body class even when region is not rendered in DOM

In the html.html.twig file of my theme if added the following code to body_classes to add a body class if a region is not empty:

page.hero ? 'w-hero-bg',

So it looks like this:

  set body_classes = (
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    db_offline ? 'db-offline',
    page.hero ? 'w-hero-bg',

I’ve created a block with views containing an ‘Hero image’. I put a filter in place which checks if there is a media id available in the ‘Hero image’ field. If there is none available, the block is empty and is not displayed.

I’ve placed this block in the Hero region (page.hero). But even when the block is not displayed, and the region is not rendered in the DOM the class ‘w-hero-bg’ is still being attached to the body.

Is this a bug or am I missing something? might be relevant, but I can’t determine if this is related as my region is not rendered in the DOM.