Problem
A page whose layout extends another layout loses everything it pushes. With
<head>@stack('styles')</head><main>@yield('content')</main><footer>@stack('scripts')</footer>
NaN
@extends('base')a page that does @extends('app') and renders an empty <footer>; the same page with @extends('base') renders the script. In a chain of three layouts, the pushes of the layout the page extends are lost too. The page's pushes are collected before its layout is processed, and a layout that extends another one is processed by a recursive processDirectives call that starts from an empty set of stacks. Sections are handed to that call through __sections; stacks were not.
Fix
The intermediate-layout branch hands its stacks to the recursive call, which starts from them, so the order is the same as with one layout: the page's pushes, then each layout's, with @prepend at the front. The hand-over is taken off the context before view composers and middleware run, so anything else rendered with that context starts with its own stacks. The pushed content's HTML comments are masked against the caller's comment table, so they move into the recursive call's table with it.
Tests
Six cases in test/directives/nested-layout-push.test.ts, including HTML comments in a pushed block and a view composer that renders a partial with the same context. On main five fail, for example:
Expected: "<b>page</b><i>mid</i><u>base</u>"
Received: "<i>mid</i><u>base</u>"The sixth, a page that extends the base layout directly, passes on main and with the change. bun run build, bun run smoke:install, bun run typecheck, bun run lint and bun run format:check pass, and bun test packages examples --max-concurrency=1 has no new failures compared with main (the tests failing on both need a browser or other parts of the environment I don't have).