2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-19 17:20:36 +03:00

fix: prevent button triggering external form submit (#389)

This commit is contained in:
mengxiong10
2019-12-04 16:25:48 +08:00
parent 0e43746b5f
commit 7fcc1df67c
4 changed files with 40 additions and 1 deletions
@@ -9,6 +9,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
>
<button
class="mx-btn mx-btn-text mx-btn-icon-double-left"
type="button"
>
<i
class="mx-icon-double-left"
@@ -17,6 +18,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-left"
type="button"
>
<i
class="mx-icon-left"
@@ -25,6 +27,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-double-right"
type="button"
>
<i
class="mx-icon-double-right"
@@ -33,6 +36,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-right"
type="button"
>
<i
class="mx-icon-right"
@@ -44,6 +48,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
>
<button
class="mx-btn mx-btn-text mx-btn-current-month"
type="button"
>
Oct
@@ -51,6 +56,7 @@ exports[`CalendarPanel prop: type=date 1`] = `
</button>
<button
class="mx-btn mx-btn-text mx-btn-current-year"
type="button"
>
2019
@@ -93,6 +99,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
>
<button
class="mx-btn mx-btn-text mx-btn-icon-double-left"
type="button"
>
<i
class="mx-icon-double-left"
@@ -102,6 +109,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-left"
style="display: none;"
type="button"
>
<i
class="mx-icon-left"
@@ -110,6 +118,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-double-right"
type="button"
>
<i
class="mx-icon-double-right"
@@ -119,6 +128,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-right"
style="display: none;"
type="button"
>
<i
class="mx-icon-right"
@@ -130,6 +140,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
>
<button
class="mx-btn mx-btn-text"
type="button"
>
2019
@@ -165,6 +176,7 @@ exports[`CalendarPanel prop: type=year 1`] = `
>
<button
class="mx-btn mx-btn-text mx-btn-icon-double-left"
type="button"
>
<i
class="mx-icon-double-left"
@@ -174,6 +186,7 @@ exports[`CalendarPanel prop: type=year 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-left"
style="display: none;"
type="button"
>
<i
class="mx-icon-left"
@@ -182,6 +195,7 @@ exports[`CalendarPanel prop: type=year 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-double-right"
type="button"
>
<i
class="mx-icon-double-right"
@@ -191,6 +205,7 @@ exports[`CalendarPanel prop: type=year 1`] = `
<button
class="mx-btn mx-btn-text mx-btn-icon-right"
style="display: none;"
type="button"
>
<i
class="mx-icon-right"
+14
View File
@@ -325,4 +325,18 @@ describe('DatePicker', () => {
el.trigger('click');
expect(wrapper.emitted().close).toBeTruthy();
});
// present the button submit form
it('the type of all buttons should be button', () => {
wrapper = mount(DatePicker, {
propsData: {
open: true,
showTimePanel: true,
},
});
const els = wrapper.findAll('button');
els.wrappers.forEach(v => {
expect(v.element.type).toBe('button');
});
});
});