@@ -501,6 +501,17 @@ public function getClasses(): string
501501 );
502502 }
503503
504+ /**
505+ * Retrieve the component attribute bag.
506+ */
507+ protected function getComponentAttributeBag (): ComponentAttributeBag
508+ {
509+ return (new ComponentAttributeBag )
510+ ->class ($ this ->getClasses ())
511+ ->style ($ this ->getInlineStyle ())
512+ ->filter (fn ($ value ) => filled ($ value ) && $ value !== '; ' );
513+ }
514+
504515 /**
505516 * Retrieve the block API version.
506517 */
@@ -778,11 +789,6 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w
778789 $ this ->style = $ this ->getStyle ();
779790 $ this ->inlineStyle = $ this ->getInlineStyle ();
780791
781- $ attributes = (new ComponentAttributeBag )
782- ->class ($ this ->classes )
783- ->style ($ this ->inlineStyle )
784- ->filter (fn ($ value ) => filled ($ value ) && $ value !== '; ' );
785-
786792 if (! is_admin () && method_exists ($ this , 'assets ' )) {
787793 $ instance = (array ) ($ this ->block ?? []);
788794
@@ -793,7 +799,7 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w
793799
794800 return $ this ->view ($ this ->view , [
795801 'block ' => $ this ,
796- 'attributes ' => $ attributes ,
802+ 'attributes ' => $ this -> getComponentAttributeBag () ,
797803 ]);
798804 }
799805
0 commit comments