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
7c64336e
Commit
7c64336e
authored
Feb 10, 2019
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "should not change method to replaceState unless asPath is the same (#6033)"
This reverts commit
ab46c451
.
parent
155423f2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
21 deletions
+5
-21
router.js
lib/router/router.js
+4
-6
as-path-pushstate.js
test/integration/basic/pages/nav/as-path-pushstate.js
+1
-10
client-navigation.js
test/integration/basic/test/client-navigation.js
+0
-5
No files found.
lib/router/router.js
View file @
7c64336e
...
@@ -164,14 +164,14 @@ export default class Router {
...
@@ -164,14 +164,14 @@ export default class Router {
return
true
return
true
}
}
const
{
pathname
:
asPathname
,
query
:
asQuery
}
=
parse
(
as
,
true
)
const
{
pathname
,
query
}
=
parse
(
url
,
true
)
const
{
pathname
,
query
}
=
parse
(
url
,
true
)
// If asked to change the current URL we should reload the current page
// If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
// as this should not go into the history (That's how browsers work)
// We should compare the new asPath to the current asPath, not the url
if
(
!
this
.
urlIsNew
(
asPathname
,
asQuery
))
{
if
(
!
this
.
urlIsNew
(
as
))
{
method
=
'replaceState'
method
=
'replaceState'
}
}
...
@@ -339,10 +339,8 @@ export default class Router {
...
@@ -339,10 +339,8 @@ export default class Router {
}
}
}
}
urlIsNew
(
asPath
)
{
urlIsNew
(
pathname
,
query
)
{
const
{
pathname
,
query
}
=
parse
(
asPath
,
true
)
return
this
.
pathname
!==
pathname
||
!
shallowEquals
(
query
,
this
.
query
)
const
{
pathname
:
curPathname
}
=
parse
(
this
.
asPath
,
true
)
return
curPathname
!==
pathname
||
!
shallowEquals
(
query
,
this
.
query
)
}
}
isShallowRoutingPossible
(
route
)
{
isShallowRoutingPossible
(
route
)
{
...
...
test/integration/basic/pages/nav/as-path-pushstate.js
View file @
7c64336e
...
@@ -9,16 +9,7 @@ export default withRouter(({router: {asPath, query}}) => {
...
@@ -9,16 +9,7 @@ export default withRouter(({router: {asPath, query}}) => {
<
a
id
=
'hello'
>
hello
<
/a
>
<
a
id
=
'hello'
>
hello
<
/a
>
<
/Link
>
<
/Link
>
<
/div
>
<
/div
>
<
div
>
<
Link
href
=
'/nav/as-path-pushstate'
as
=
'/something/else'
>
<
a
id
=
'else'
>
else
<
/a
>
<
/Link
>
<
/div
>
<
div
>
<
Link
href
=
'/nav/as-path-pushstate'
as
=
'/nav/as-path-pushstate'
>
<
a
id
=
'hello2'
>
normal
hello
<
/a
>
<
/Link
>
<
/div
>
{
query
.
something
===
'hello'
&&
<
Link
href
=
'/nav/as-path-pushstate?something=hello'
as
=
'/something/same-query'
>
{
query
.
something
===
'hello'
&&
<
Link
href
=
'/nav/as-path-pushstate?something=hello'
as
=
'/something/same-query'
>
<
a
id
=
'same-query'
>
same
query
<
/a
>
<
a
id
=
'same-query'
>
same
query
<
/a
>
<
/Link>
}
<
/Link>
}
...
...
test/integration/basic/test/client-navigation.js
View file @
7c64336e
...
@@ -648,11 +648,6 @@ export default (context, render) => {
...
@@ -648,11 +648,6 @@ export default (context, render) => {
await
browser
.
back
().
waitForElementByCss
(
'#something-hello'
)
await
browser
.
back
().
waitForElementByCss
(
'#something-hello'
)
const
queryThree
=
JSON
.
parse
(
await
browser
.
elementByCss
(
'#router-query'
).
text
())
const
queryThree
=
JSON
.
parse
(
await
browser
.
elementByCss
(
'#router-query'
).
text
())
expect
(
queryThree
.
something
).
toBe
(
'hello'
)
expect
(
queryThree
.
something
).
toBe
(
'hello'
)
await
browser
.
elementByCss
(
'#else'
).
click
().
waitForElementByCss
(
'#something-else'
)
await
browser
.
elementByCss
(
'#hello2'
).
click
().
waitForElementByCss
(
'#nav-as-path-pushstate'
)
await
browser
.
back
().
waitForElementByCss
(
'#something-else'
)
const
queryFour
=
JSON
.
parse
(
await
browser
.
elementByCss
(
'#router-query'
).
text
())
expect
(
queryFour
.
something
).
toBe
(
undefined
)
}
finally
{
}
finally
{
if
(
browser
)
{
if
(
browser
)
{
browser
.
close
()
browser
.
close
()
...
...
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