mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
rename filterComparator to filterMatch, fix tests
This commit is contained in:
@@ -576,15 +576,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to determine if the provided option
|
* Callback to determine if the provided option should
|
||||||
* should match the current search text.
|
* match the current search text. Used to determine
|
||||||
|
* if the option should be displayed.
|
||||||
* @type {Function}
|
* @type {Function}
|
||||||
* @param {Object || String} option
|
* @param {Object || String} option
|
||||||
* @param {String} label
|
* @param {String} label
|
||||||
* @param {String} search
|
* @param {String} search
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
filterComparator: {
|
filterMatch: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default(option, label, search) {
|
default(option, label, search) {
|
||||||
return (label || '').toLowerCase().indexOf(search.toLowerCase()) > -1
|
return (label || '').toLowerCase().indexOf(search.toLowerCase()) > -1
|
||||||
@@ -608,7 +609,7 @@
|
|||||||
if (typeof label === 'number') {
|
if (typeof label === 'number') {
|
||||||
label = label.toString()
|
label = label.toString()
|
||||||
}
|
}
|
||||||
return this.filterComparator(option, label, search)
|
return this.filterMatch(option, label, search)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
it('can determine if a given option should match the current search text', () => {
|
it('can determine if a given option should match the current search text', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select ref="select" :filterFunction="customFn" :options="[{label: 'Aoo', value: 'foo'}, {label: 'Bar', value: 'bar'}, {label: 'Baz', value: 'baz'}]" v-model="value"></v-select></div>`,
|
template: `<div><v-select ref="select" :filter-match="customFn" :options="[{label: 'Aoo', value: 'foo'}, {label: 'Bar', value: 'bar'}, {label: 'Baz', value: 'baz'}]" v-model="value"></v-select></div>`,
|
||||||
data: {value: 'foo'},
|
data: {value: 'foo'},
|
||||||
methods:{
|
methods:{
|
||||||
customFn: (option, label, search) => label.match(new RegExp('^' + search, 'i'))
|
customFn: (option, label, search) => label.match(new RegExp('^' + search, 'i'))
|
||||||
|
|||||||
Reference in New Issue
Block a user