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
d4d5ad4b
Commit
d4d5ad4b
authored
Aug 06, 2019
by
Luis Fernando Alvarez D
Committed by
Tim Neutkens
Aug 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove propertyFields from the client router (#8219)
* Remove forEach over the components prop * Remove propertyFields
parent
beed65be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
15 deletions
+2
-15
router.ts
packages/next/client/router.ts
+2
-15
No files found.
packages/next/client/router.ts
View file @
d4d5ad4b
...
@@ -29,8 +29,7 @@ const singletonRouter: SingletonRouterBase = {
...
@@ -29,8 +29,7 @@ const singletonRouter: SingletonRouterBase = {
}
}
// Create public properties and methods of the router in the singletonRouter
// Create public properties and methods of the router in the singletonRouter
const
urlPropertyFields
=
[
'pathname'
,
'route'
,
'query'
,
'asPath'
]
const
urlPropertyFields
=
[
'pathname'
,
'route'
,
'query'
,
'asPath'
,
'components'
]
const
propertyFields
=
[
'components'
]
const
routerEvents
=
[
const
routerEvents
=
[
'routeChangeStart'
,
'routeChangeStart'
,
'beforeHistoryChange'
,
'beforeHistoryChange'
,
...
@@ -55,7 +54,7 @@ Object.defineProperty(singletonRouter, 'events', {
...
@@ -55,7 +54,7 @@ Object.defineProperty(singletonRouter, 'events', {
},
},
})
})
propertyFields
.
concat
(
urlPropertyFields
)
.
forEach
(
field
=>
{
urlPropertyFields
.
forEach
(
field
=>
{
// Here we need to use Object.defineProperty because, we need to return
// Here we need to use Object.defineProperty because, we need to return
// the property assigned to the actual router
// the property assigned to the actual router
// The value might get changed as we change routes and this is the
// The value might get changed as we change routes and this is the
...
@@ -149,18 +148,6 @@ export function makePublicRouterInstance(router: Router): NextRouter {
...
@@ -149,18 +148,6 @@ export function makePublicRouterInstance(router: Router): NextRouter {
// Events is a static property on the router, the router doesn't have to be initialized to use it
// Events is a static property on the router, the router doesn't have to be initialized to use it
instance
.
events
=
Router
.
events
instance
.
events
=
Router
.
events
propertyFields
.
forEach
(
field
=>
{
// Here we need to use Object.defineProperty because, we need to return
// the property assigned to the actual router
// The value might get changed as we change routes and this is the
// proper way to access it
Object
.
defineProperty
(
instance
,
field
,
{
get
()
{
return
_router
[
field
]
},
})
})
coreMethodFields
.
forEach
(
field
=>
{
coreMethodFields
.
forEach
(
field
=>
{
instance
[
field
]
=
(...
args
:
any
[])
=>
{
instance
[
field
]
=
(...
args
:
any
[])
=>
{
return
_router
[
field
](...
args
)
return
_router
[
field
](...
args
)
...
...
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