Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
3f62f5bc
Commit
3f62f5bc
authored
Apr 03, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add conflicting metadata test and explanatory comments
parent
aa5e44d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
2 deletions
+36
-2
resolve-metadata.ts
packages/next/src/lib/metadata/resolve-metadata.ts
+10
-2
page.tsx
...outes/app/parallel-routes/@bar/metadata-conflict/page.tsx
+7
-0
page.tsx
...outes/app/parallel-routes/@foo/metadata-conflict/page.tsx
+3
-0
page.tsx
...lel-routes/app/parallel-routes/metadata-conflict/page.tsx
+7
-0
metadata-streaming-parallel-routes.test.ts
...arallel-routes/metadata-streaming-parallel-routes.test.ts
+9
-0
No files found.
packages/next/src/lib/metadata/resolve-metadata.ts
View file @
3f62f5bc
...
@@ -788,7 +788,11 @@ async function resolveMetadataItemsImpl(
...
@@ -788,7 +788,11 @@ async function resolveMetadataItemsImpl(
.
join
(
'/'
),
.
join
(
'/'
),
})
})
// Process children first, then other parallel routes, for consistent ordering
// Process children first so named parallel route slots are pushed to
// metadataItems last. Since accumulateMetadata applies last-write-wins,
// named slots take precedence over children when both define metadata.
// This ensures deterministic behavior across webpack and Turbopack,
// which may construct loader trees with different key orderings.
const
metadataParallelRouteKeys
=
Object
.
keys
(
parallelRoutes
)
const
metadataParallelRouteKeys
=
Object
.
keys
(
parallelRoutes
)
metadataParallelRouteKeys
.
sort
((
a
,
b
)
=>
{
metadataParallelRouteKeys
.
sort
((
a
,
b
)
=>
{
if
(
a
===
'children'
)
return
-
1
if
(
a
===
'children'
)
return
-
1
...
@@ -918,7 +922,11 @@ async function resolveViewportItemsImpl(
...
@@ -918,7 +922,11 @@ async function resolveViewportItemsImpl(
.
join
(
'/'
),
.
join
(
'/'
),
})
})
// Process children first, then other parallel routes, for consistent ordering
// Process children first so named parallel route slots are pushed to
// viewportItems last. Since accumulateViewport applies last-write-wins,
// named slots take precedence over children when both define viewport.
// This ensures deterministic behavior across webpack and Turbopack,
// which may construct loader trees with different key orderings.
const
viewportParallelRouteKeys
=
Object
.
keys
(
parallelRoutes
)
const
viewportParallelRouteKeys
=
Object
.
keys
(
parallelRoutes
)
viewportParallelRouteKeys
.
sort
((
a
,
b
)
=>
{
viewportParallelRouteKeys
.
sort
((
a
,
b
)
=>
{
if
(
a
===
'children'
)
return
-
1
if
(
a
===
'children'
)
return
-
1
...
...
test/e2e/app-dir/metadata-streaming-parallel-routes/app/parallel-routes/@bar/metadata-conflict/page.tsx
0 → 100644
View file @
3f62f5bc
export
default
function
Page
()
{
return
<
div
id=
"bar-conflict-page"
>
bar slot page
</
div
>
}
export
const
metadata
=
{
title
:
'bar slot title'
,
}
test/e2e/app-dir/metadata-streaming-parallel-routes/app/parallel-routes/@foo/metadata-conflict/page.tsx
0 → 100644
View file @
3f62f5bc
export
default
function
Page
()
{
return
<
div
id=
"foo-conflict-page"
>
foo slot page
</
div
>
}
test/e2e/app-dir/metadata-streaming-parallel-routes/app/parallel-routes/metadata-conflict/page.tsx
0 → 100644
View file @
3f62f5bc
export
default
function
Page
()
{
return
<
div
id=
"children-page"
>
children page
</
div
>
}
export
const
metadata
=
{
title
:
'children title'
,
}
test/e2e/app-dir/metadata-streaming-parallel-routes/metadata-streaming-parallel-routes.test.ts
View file @
3f62f5bc
...
@@ -59,6 +59,15 @@ describe('app-dir - metadata-streaming', () => {
...
@@ -59,6 +59,15 @@ describe('app-dir - metadata-streaming', () => {
expect
(
$
(
'body title'
).
text
()).
toBe
(
'parallel-routes-default layout title'
)
expect
(
$
(
'body title'
).
text
()).
toBe
(
'parallel-routes-default layout title'
)
})
})
it
(
'should use named slot metadata over children when both define conflicting metadata'
,
async
()
=>
{
const
$
=
await
next
.
render$
(
'/parallel-routes/metadata-conflict'
)
expect
(
$
(
'title'
).
text
()).
toBe
(
'bar slot title'
)
const
browser
=
await
next
.
browser
(
'/parallel-routes/metadata-conflict'
)
expect
(
await
browser
.
elementByCss
(
'title'
).
text
()).
toBe
(
'bar slot title'
)
expect
((
await
browser
.
elementsByCss
(
'title'
)).
length
).
toBe
(
1
)
})
it
(
'should change metadata when navigating between two pages under a slot when children is not rendered'
,
async
()
=>
{
it
(
'should change metadata when navigating between two pages under a slot when children is not rendered'
,
async
()
=>
{
// first page is /parallel-routes-no-children/first,
// first page is /parallel-routes-no-children/first,
// second page is /parallel-routes-no-children/second
// second page is /parallel-routes-no-children/second
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment