( instance: ComponentInternalInstance, rawProps: Data | null, isStateful: number, // result of bitwise flag comparison isSSR = false, )
| 192 | export type NormalizedPropsOptions = [NormalizedProps, string[]] | [] |
| 193 | |
| 194 | export function initProps( |
| 195 | instance: ComponentInternalInstance, |
| 196 | rawProps: Data | null, |
| 197 | isStateful: number, // result of bitwise flag comparison |
| 198 | isSSR = false, |
| 199 | ): void { |
| 200 | const props: Data = {} |
| 201 | const attrs: Data = createInternalObject() |
| 202 | |
| 203 | instance.propsDefaults = Object.create(null) |
| 204 | |
| 205 | setFullProps(instance, rawProps, props, attrs) |
| 206 | |
| 207 | // ensure all declared prop keys are present |
| 208 | for (const key in instance.propsOptions[0]) { |
| 209 | if (!(key in props)) { |
| 210 | props[key] = undefined |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | // validation |
| 215 | if (__DEV__) { |
| 216 | validateProps(rawProps || {}, props, instance) |
| 217 | } |
| 218 | |
| 219 | if (isStateful) { |
| 220 | // stateful |
| 221 | instance.props = isSSR ? props : shallowReactive(props) |
| 222 | } else { |
| 223 | if (!instance.type.props) { |
| 224 | // functional w/ optional props, props === attrs |
| 225 | instance.props = attrs |
| 226 | } else { |
| 227 | // functional w/ declared props |
| 228 | instance.props = props |
| 229 | } |
| 230 | } |
| 231 | instance.attrs = attrs |
| 232 | } |
| 233 | |
| 234 | function isInHmrContext(instance: ComponentInternalInstance | null) { |
| 235 | while (instance) { |
no test coverage detected