mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
feat: move uid to props (#1362)
* Add uniqueKey prop * move uid to prop * Update props.md Co-authored-by: TheJaredWilcurt <4629794+TheJaredWilcurt@users.noreply.github.com> Co-authored-by: Jeff Sagal <sagalbot@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4bb24bfb7f
commit
bf8be2ec26
@@ -569,6 +569,18 @@ transition: {
|
||||
},
|
||||
```
|
||||
|
||||
## uid
|
||||
|
||||
A unique identifier used to generate IDs and DOM attributes.
|
||||
Must be unique for every instance of the component.
|
||||
|
||||
```js
|
||||
uid: {
|
||||
type: [String, Number],
|
||||
default: () => uniqueId(),
|
||||
},
|
||||
```
|
||||
|
||||
|
||||
## value
|
||||
|
||||
|
||||
@@ -656,11 +656,19 @@ export default {
|
||||
return noDrop ? false : open && !mutableLoading
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A unique identifier used to generate IDs in HTML.
|
||||
* Must be unique for every instance of the component.
|
||||
*/
|
||||
uid: {
|
||||
type: [String, Number],
|
||||
default: () => uniqueId(),
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
uid: uniqueId(),
|
||||
search: '',
|
||||
open: false,
|
||||
isComposing: false,
|
||||
|
||||
@@ -33,3 +33,15 @@ describe('Search Slot Scope', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('UID', () => {
|
||||
it('works with strings', () => {
|
||||
const Select = mountDefault({ uid: 'hello' })
|
||||
expect(Select.find('#vshello__combobox').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('works with numbers', () => {
|
||||
const Select = mountDefault({ uid: 2 })
|
||||
expect(Select.find('#vs2__combobox').exists()).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user