Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
79325390
Commit
79325390
authored
Apr 09, 2018
by
Brandon
Committed by
杨奕
Apr 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pagination: handle NaN on props (#10623)
* Pagination: handle pageSize NaN * Pagination: handle currentPage NaN
parent
6f4f5717
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
15 deletions
+39
-15
packages/pagination/src/pagination.js
packages/pagination/src/pagination.js
+18
-15
test/unit/specs/pagination.spec.js
test/unit/specs/pagination.spec.js
+21
-0
No files found.
packages/pagination/src/pagination.js
View file @
79325390
...
...
@@ -375,27 +375,30 @@ export default {
pageSize
:
{
immediate
:
true
,
handler
(
val
)
{
this
.
internalPageSize
=
val
;
this
.
internalPageSize
=
isNaN
(
val
)
?
10
:
val
;
}
},
internalCurrentPage
(
newVal
,
oldVal
)
{
newVal
=
parseInt
(
newVal
,
10
);
/* istanbul ignore if */
if
(
isNaN
(
newVal
))
{
newVal
=
oldVal
||
1
;
}
else
{
newVal
=
this
.
getValidCurrentPage
(
newVal
);
}
internalCurrentPage
:
{
immediate
:
true
,
handler
(
newVal
,
oldVal
)
{
newVal
=
parseInt
(
newVal
,
10
);
/* istanbul ignore if */
if
(
isNaN
(
newVal
))
{
newVal
=
oldVal
||
1
;
}
else
{
newVal
=
this
.
getValidCurrentPage
(
newVal
);
}
if
(
newVal
!==
undefined
)
{
this
.
internalCurrentPage
=
newVal
;
if
(
oldVal
!==
newVal
)
{
if
(
newVal
!==
undefined
)
{
this
.
internalCurrentPage
=
newVal
;
if
(
oldVal
!==
newVal
)
{
this
.
$emit
(
'
update:currentPage
'
,
newVal
);
}
}
else
{
this
.
$emit
(
'
update:currentPage
'
,
newVal
);
}
}
else
{
this
.
$emit
(
'
update:currentPage
'
,
newVal
);
}
},
...
...
test/unit/specs/pagination.spec.js
View file @
79325390
...
...
@@ -82,6 +82,16 @@ describe('Pagination', () => {
expect
(
vm
.
$el
.
querySelectorAll
(
'
li.number
'
)).
to
.
length
(
4
);
});
it
(
'
pageSize: NaN
'
,
()
=>
{
vm
=
createTest
(
Pagination
,
{
pageSize
:
NaN
,
total
:
100
});
const
pagers
=
vm
.
$el
.
querySelectorAll
(
'
li.number
'
);
expect
(
pagers
).
to
.
length
(
7
);
});
it
(
'
pageCount
'
,
()
=>
{
const
vm
=
createTest
(
Pagination
,
{
pageSize
:
25
,
...
...
@@ -119,6 +129,17 @@ describe('Pagination', () => {
expect
(
vm
.
$el
.
querySelector
(
'
li.number.active
'
)).
to
.
have
.
property
(
'
textContent
'
).
to
.
equal
(
'
3
'
);
});
it
(
'
currentPage: NaN
'
,
()
=>
{
vm
=
createTest
(
Pagination
,
{
pageSize
:
20
,
total
:
200
,
currentPage
:
NaN
});
expect
(
vm
.
$el
.
querySelector
(
'
li.number.active
'
)).
to
.
have
.
property
(
'
textContent
'
).
to
.
equal
(
'
1
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
li.number
'
)).
to
.
length
(
7
);
});
it
(
'
set currentPage & total
'
,
(
done
)
=>
{
vm
=
createVue
({
template
:
`
...
...
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