Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 9x 9x 9x 9x 12x 9x 11x 3x 5x 3x 9x 28x 28x 9x 13x 6x | import { looseEqual, looseIndexOf, isArray } from '@vue/shared'
import { ssrRenderAttr } from './ssrRenderAttrs'
export const ssrLooseEqual = looseEqual as (a: unknown, b: unknown) => boolean
export function ssrLooseContain(arr: unknown[], value: unknown): boolean {
return looseIndexOf(arr, value) > -1
}
// for <input :type="type" v-model="model" value="value">
export function ssrRenderDynamicModel(
type: unknown,
model: unknown,
value: unknown
) {
switch (type) {
case 'radio':
return looseEqual(model, value) ? ' checked' : ''
case 'checkbox':
return (isArray(model) ? ssrLooseContain(model, value) : model)
? ' checked'
: ''
default:
// text types
return ssrRenderAttr('value', model)
}
}
// for <input v-bind="obj" v-model="model">
export function ssrGetDynamicModelProps(
existingProps: any = {},
model: unknown
) {
const { type, value } = existingProps
switch (type) {
case 'radio':
return looseEqual(model, value) ? { checked: true } : null
case 'checkbox':
return (isArray(model) ? ssrLooseContain(model, value) : model)
? { checked: true }
: null
default:
// text types
return { value: model }
}
}
|