diff --git a/src/EventSubscriber/LayoutBuilderIdsRenderSubscriber.php b/src/EventSubscriber/LayoutBuilderIdsRenderSubscriber.php
index 58a61f037aeac86ef3979548492690a5e16c2f23..8e3edf8762cdfa291388b9c2d6645df999f72822 100644
--- a/src/EventSubscriber/LayoutBuilderIdsRenderSubscriber.php
+++ b/src/EventSubscriber/LayoutBuilderIdsRenderSubscriber.php
@@ -43,7 +43,7 @@ class LayoutBuilderIdsRenderSubscriber implements EventSubscriberInterface {
     $layout_builder_id = $event->getComponent()->get('layout_builder_id');
 
     // If there is a layout builder id, then set it in the attributes.
-    if ($layout_builder_id !== NULL && $layout_builder_id !== '') {
+    if ((string) $layout_builder_id) {
 
       // Set the id attribute.
       $build['#attributes']['id'] = $layout_builder_id;