Skip to content

Commit fd97359

Browse files
committed
Adjust detecting whether a passed component is deferred
1 parent 10034c5 commit fd97359

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/LiveComponent/src/EventListener/AddLiveAttributesSubscriber.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,10 @@ public function onPreRender(PreRenderEvent $event): void
7474
);
7575
}
7676

77-
$hasLiveId = isset($originalAttributes['data-live-id']);
78-
$isDeferred = \array_key_exists('defer', $originalAttributes);
79-
$loadingTemplate = $originalAttributes['defer-loading-template'] ?? null;
80-
81-
// if the original attributes has a data-live-id, it means the component
82-
// was already rendered
83-
if (!$hasLiveId && $isDeferred) {
84-
$attributes = $attributes->without('defer', 'defer-loading-template');
77+
$inputProps = $event->getMountedComponent()->getInputProps();
78+
$isDeferred = array_key_exists('defer', $inputProps);
79+
80+
if ($isDeferred) {
8581
$event->setTemplate('@LiveComponent/deferred.html.twig');
8682

8783
if ($loadingTemplate) {

0 commit comments

Comments
 (0)