Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Add input-id parameter to avoid id collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomka committed Jul 9, 2018
1 parent d869892 commit d3d9797
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Parameter | Type | Default | Description
--------- | ---- | ------- | -----------
v-model (*required*) | ISO 8601 `String` | - | Datetime.
type | `String` | `date` | Picker type. date or datetime.
input-id | `String` | `''` | Id for the input.
input-class | `String` | `''` | Class for the input.
hidden-name | `String` | `null` | Name for hidden input with raw value. See #51.
value-zone | `String` | `UTC` | Time zone for the value.
Expand Down
5 changes: 5 additions & 0 deletions src/Datetime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="vdatetime">
<input class="vdatetime-input"
:class="inputClass"
:id="inputId"
type="text"
:value="inputValue"
v-bind="$attrs"
Expand Down Expand Up @@ -48,6 +49,10 @@ export default {
type: String,
default: 'UTC'
},
inputId: {
type: String,
default: ''
},
inputClass: {
type: String,
default: ''
Expand Down
10 changes: 10 additions & 0 deletions test/specs/Datetime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ describe('Datetime.vue', function () {
expect(vm.$('.vdatetime-input')).to.have.class('class-name')
})

it('should add id to input', function () {
const vm = createVM(this,
`<Datetime input-id="id-name"></Datetime>`,
{
components: { Datetime }
})

expect(vm.$('.vdatetime-input')).to.have.id('id-name')
})

it('input should inherit attributes', function () {
const vm = createVM(this,
`<Datetime placeholder="Select date..."></Datetime>`,
Expand Down

0 comments on commit d3d9797

Please sign in to comment.