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
76e86e0f
Unverified
Commit
76e86e0f
authored
Sep 12, 2020
by
Markus Lautenbach
Committed by
GitHub
Sep 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove false positive in circular structure detection (#16380)
Co-authored-by:
Joe Haddad
<
joe.haddad@zeit.co
>
parent
71c5ab62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
is-serializable-props.ts
packages/next/lib/is-serializable-props.ts
+8
-3
is-serializable-props.test.js
test/unit/is-serializable-props.test.js
+9
-0
No files found.
packages/next/lib/is-serializable-props.ts
View file @
76e86e0f
...
...
@@ -98,11 +98,16 @@ export function isSerializableProps(
if
(
Array
.
isArray
(
value
))
{
visit
(
refs
,
value
,
path
)
const
seen
=
new
Set
<
any
>
()
const
newRefs
=
new
Map
(
refs
)
if
(
value
.
every
((
nestedValue
,
index
)
=>
isSerializable
(
newRefs
,
nestedValue
,
`
${
path
}
[
${
index
}
]`
)
)
value
.
every
((
nestedValue
,
index
)
=>
{
if
(
seen
.
has
(
nestedValue
))
{
return
true
}
seen
.
add
(
nestedValue
)
return
isSerializable
(
newRefs
,
nestedValue
,
`
${
path
}
[
${
index
}
]`
)
})
)
{
return
true
}
...
...
test/unit/is-serializable-props.test.js
View file @
76e86e0f
...
...
@@ -275,4 +275,13 @@ Reason: Circular references cannot be expressed in JSON (references: \`.k\`)."
})
).
toBe
(
true
)
})
it
(
'allows identical object instances in an array'
,
()
=>
{
const
obj
=
{
foo
:
'bar'
}
const
arr
=
[
obj
,
obj
]
const
objWithArr
=
{
deep
:
{
arr
}
}
expect
(
isSerializableProps
(
'/'
,
'test'
,
{
arr
})).
toBe
(
true
)
expect
(
isSerializableProps
(
'/'
,
'test'
,
{
objWithArr
})).
toBe
(
true
)
})
})
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