Skip to content

Commit 2381089

Browse files
committed
feat: add prop inputAttr
1 parent 1d0a67b commit 2381089

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export default {
9292
| first-day-of-week | Number | 7 | set the first day of week (1-7) |
9393
| input-class | String | 'mx-input' | the input class name |
9494
| input-name | String | 'date' | the input name attr |
95+
| input-attr | Object | | the input attr(eg: { required: true, id: 'input'}) |
9596
| confirm-text | String | 'OK' | the default text to display on confirm button |
9697
| range-separator | String | '~' | the range separator text |
9798
| date-format | String | '' | format the time header and tooltip |

src/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
<div class="mx-input-wrapper"
1313
@click="showPopup">
1414
<input
15+
:class="inputClass"
16+
:name="inputName"
17+
v-bind="inputAttr"
1518
ref="input"
1619
type="text"
1720
autocomplete="off"
18-
:class="inputClass"
19-
:name="inputName"
2021
:disabled="disabled"
2122
:readonly="!editable"
2223
:value="text"
@@ -185,6 +186,7 @@ export default {
185186
type: [String, Array],
186187
default: 'mx-input'
187188
},
189+
inputAttr: Object,
188190
appendToBody: {
189191
type: Boolean,
190192
default: false

test/index.spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ afterEach(() => {
1313
})
1414

1515
describe('datepicker', () => {
16+
it('prop: inputAttr', () => {
17+
wrapper = mount(DatePicker, {
18+
propsData: {
19+
inputAttr: { required: true, id: 'input' }
20+
}
21+
})
22+
const input = wrapper.find('input').element
23+
expect(input).toHaveProperty('required', true)
24+
expect(input).toHaveProperty('id', 'input')
25+
})
26+
1627
it('prop: appendToBody', () => {
1728
wrapper = mount(DatePicker, {
1829
propsData: {
@@ -366,7 +377,9 @@ describe('calendar-panel', () => {
366377

367378
it('click: prev/next year', () => {
368379
wrapper = mount(CalendarPanel, {
369-
value: new Date(2018, 4, 5)
380+
propsData: {
381+
value: new Date(2018, 4, 5)
382+
}
370383
})
371384
const nextBtn = wrapper.find('.mx-icon-next-year')
372385
const lastBtn = wrapper.find('.mx-icon-last-year')

0 commit comments

Comments
 (0)