feat(runtime-dom): allow native Set as v-model checkbox source (#1957)

This commit is contained in:
Pick
2020-09-14 23:16:50 +08:00
committed by GitHub
parent 542680e478
commit cf1b6c666f
4 changed files with 104 additions and 4 deletions

View File

@@ -58,6 +58,9 @@ export const hasOwn = (
): key is keyof typeof val => hasOwnProperty.call(val, key)
export const isArray = Array.isArray
export const isSet = (val: any): boolean => {
return toRawType(val) === 'Set'
}
export const isDate = (val: unknown): val is Date => val instanceof Date
export const isFunction = (val: unknown): val is Function =>
typeof val === 'function'

View File

@@ -51,3 +51,10 @@ export function looseEqual(a: any, b: any): boolean {
export function looseIndexOf(arr: any[], val: any): number {
return arr.findIndex(item => looseEqual(item, val))
}
export function looseHas(set: Set<any>, val: any): boolean {
for (let item of set) {
if (looseEqual(item, val)) return true
}
return false
}