@@ -97,7 +97,6 @@ protected function compileComponentTag(ComponentNode $node, ComponentSource $sou
9797 {
9898 $ hash = Utils::hash ($ source ->path );
9999 $ functionName = ($ this ->manager ->isFolding () ? '__ ' : '_ ' ) . $ hash ;
100- $ slotsVariableName = '$slots ' . $ hash ;
101100 [$ attributesArrayString , $ boundKeysArrayString ] = $ this ->getAttributesAndBoundKeysArrayStrings ($ node ->attributeString );
102101
103102 $ output = '< ' . '?php $__blaze->ensureRequired( \'' . $ source ->path . '\', $__blaze->compiledPath. \'/ ' . $ hash . '.php \'); ?> ' . "\n" ;
@@ -106,12 +105,18 @@ protected function compileComponentTag(ComponentNode $node, ComponentSource $sou
106105 $ output .= '< ' . '?php $__blaze->pushData( ' . $ attributesArrayString . '); ?> ' . "\n" ;
107106 $ output .= '< ' . '?php ' . $ functionName . '($__blaze, ' . $ attributesArrayString . ', [], ' . $ boundKeysArrayString . ', isset($this) ? $this : null); ?> ' . "\n" ;
108107 } else {
108+ $ slotsVariableName = '$__slots ' . $ hash ;
109109 $ attributesVariableName = '$__attrs ' . $ hash ;
110+ $ output .= '< ' . '?php if (isset( ' . $ slotsVariableName . ')) $__slotsOriginal = ' . $ slotsVariableName . '; ?> ' . "\n" ;
111+ $ output .= '< ' . '?php if (isset( ' . $ attributesVariableName . ')) $__attrsOriginal = ' . $ attributesVariableName . '; ?> ' . "\n" ;
110112 $ output .= '< ' . '?php ' . $ attributesVariableName . ' = ' . $ attributesArrayString . '; ?> ' . "\n" ;
113+ $ output .= '< ' . '?php ' . $ slotsVariableName . ' = []; ?> ' . "\n" ;
114+ $ output .= $ this ->slotCompiler ->compile ($ slotsVariableName , $ node ->children );
111115 $ output .= '< ' . '?php $__blaze->pushData( ' . $ attributesVariableName . '); ?> ' . "\n" ;
112- $ output .= $ this ->slotCompiler ->compile ($ slotsVariableName , $ node ->children ) . "\n" ;
113116 $ output .= '< ' . '?php $__blaze->pushSlots( ' . $ slotsVariableName . '); ?> ' . "\n" ;
114117 $ output .= '< ' . '?php ' . $ functionName . '($__blaze, ' . $ attributesVariableName . ', ' . $ slotsVariableName . ', ' . $ boundKeysArrayString . ', isset($this) ? $this : null); ?> ' . "\n" ;
118+ $ output .= '< ' . '?php if (isset($__slotsOriginal)) { ' . $ slotsVariableName . ' = $__slotsOriginal; unset($__slotsOriginal); } ?> ' . "\n" ;
119+ $ output .= '< ' . '?php if (isset($__attrsOriginal)) { ' . $ attributesVariableName . ' = $__attrsOriginal; unset($__attrsOriginal); } ?> ' . "\n" ;
115120 }
116121
117122 $ output .= '< ' . '?php $__blaze->popData(); ?> ' ;
@@ -125,23 +130,22 @@ protected function compileComponentTag(ComponentNode $node, ComponentSource $sou
125130 protected function compileDelegateComponentTag (ComponentNode $ node ): string
126131 {
127132 $ componentName = "'flux::' . " . $ node ->attributes ['component ' ]->value ;
128-
129- $ output = '< ' . '?php $__resolved = $__blaze->resolve( ' . $ componentName . '); ?> ' . "\n" ;
130-
131- $ slotsVariableName = '$slots ' . hash ('xxh128 ' , $ componentName );
132-
133133 $ functionName = '( \'' . ($ this ->manager ->isFolding () ? '__ ' : '_ ' ) . '\' . $__resolved) ' ;
134-
134+
135+ $ output = '< ' . '?php $__resolved = $__blaze->resolve( ' . $ componentName . '); ?> ' . "\n" ;
135136 $ output .= '< ' . '?php $__blaze->pushData($attributes->all()); ?> ' . "\n" ;
136-
137137 $ output .= '< ' . '?php if ($__resolved !== false): ?> ' . "\n" ;
138138
139139 if ($ node ->selfClosing ) {
140140 $ output .= '< ' . '?php ' . $ functionName . '($__blaze, $attributes->all(), $__blaze->mergedComponentSlots(), [], isset($this) ? $this : null); ?> ' . "\n" ;
141141 } else {
142+ $ slotsVariableName = '$__slots ' . Utils::hash ($ componentName );
143+ $ output .= '< ' . '?php if (isset( ' . $ slotsVariableName . ')) $__slotsOriginal = ' . $ slotsVariableName . '; ?> ' . "\n" ;
144+ $ output .= '< ' . '?php ' . $ slotsVariableName . ' = []; ?> ' . "\n" ;
142145 $ output .= $ this ->slotCompiler ->compile ($ slotsVariableName , $ node ->children );
143146 $ output .= '< ' . '?php ' . $ slotsVariableName . ' = array_merge($__blaze->mergedComponentSlots(), ' . $ slotsVariableName . '); ?> ' . "\n" ;
144147 $ output .= '< ' . '?php ' . $ functionName . '($__blaze, $attributes->all(), ' . $ slotsVariableName . ', [], isset($this) ? $this : null); ?> ' . "\n" ;
148+ $ output .= '< ' . '?php if (isset($__slotsOriginal)) { ' . $ slotsVariableName . ' = $__slotsOriginal; unset($__slotsOriginal); } ?> ' . "\n" ;
145149 }
146150
147151 $ output .= '< ' . '?php else: ?> ' . "\n" ;
0 commit comments