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 , value ) { return looseIndexOf ( arr , value ) > - 1 ; } export function ssrRenderDynamicModel ( type , model , value ) { switch ( type ) { case 'radio' : return looseEqual ( model , value ) ? ' checked' : '' ; case 'checkbox' : return ( isArray ( model ) ? ssrLooseContain ( model , value ) : model ) ? ' checked' : '' ; default : return ssrRenderAttr ( 'value' , model ) ; } } export function ssrGetDynamicModelProps ( existingProps = { } , model ) { 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 : return { value : model } ; } }