Commit 79325390 authored by Brandon's avatar Brandon Committed by 杨奕

Pagination: handle NaN on props (#10623)

* Pagination: handle pageSize NaN

* Pagination: handle currentPage NaN
parent 6f4f5717
......@@ -375,11 +375,13 @@ export default {
pageSize: {
immediate: true,
handler(val) {
this.internalPageSize = val;
this.internalPageSize = isNaN(val) ? 10 : val;
}
},
internalCurrentPage(newVal, oldVal) {
internalCurrentPage: {
immediate: true,
handler(newVal, oldVal) {
newVal = parseInt(newVal, 10);
/* istanbul ignore if */
......@@ -397,6 +399,7 @@ export default {
} else {
this.$emit('update:currentPage', newVal);
}
}
},
internalPageCount(newVal) {
......
......@@ -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: `
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment