(
instance: Instance,
type: string,
oldProps: Props,
newProps: Props,
keepChildren: boolean,
children: ?$ReadOnlyArray<Instance>,
)
| 241 | } |
| 242 | |
| 243 | function cloneInstance( |
| 244 | instance: Instance, |
| 245 | type: string, |
| 246 | oldProps: Props, |
| 247 | newProps: Props, |
| 248 | keepChildren: boolean, |
| 249 | children: ?$ReadOnlyArray<Instance>, |
| 250 | ): Instance { |
| 251 | if (__DEV__) { |
| 252 | checkPropStringCoercion(newProps.children, 'children'); |
| 253 | } |
| 254 | const clone = { |
| 255 | id: instance.id, |
| 256 | type: type, |
| 257 | parent: instance.parent, |
| 258 | children: keepChildren ? instance.children : (children ?? []), |
| 259 | text: shouldSetTextContent(type, newProps) |
| 260 | ? computeText((newProps.children: any) + '', instance.context) |
| 261 | : null, |
| 262 | prop: newProps.prop, |
| 263 | hidden: !!newProps.hidden, |
| 264 | context: instance.context, |
| 265 | }; |
| 266 | |
| 267 | if (type === 'suspensey-thing' && typeof newProps.src === 'string') { |
| 268 | clone.src = newProps.src; |
| 269 | } |
| 270 | |
| 271 | Object.defineProperty(clone, 'id', { |
| 272 | value: clone.id, |
| 273 | enumerable: false, |
| 274 | }); |
| 275 | Object.defineProperty(clone, 'parent', { |
| 276 | value: clone.parent, |
| 277 | enumerable: false, |
| 278 | }); |
| 279 | Object.defineProperty(clone, 'text', { |
| 280 | value: clone.text, |
| 281 | enumerable: false, |
| 282 | }); |
| 283 | Object.defineProperty(clone, 'context', { |
| 284 | value: clone.context, |
| 285 | enumerable: false, |
| 286 | }); |
| 287 | hostCloneCounter++; |
| 288 | return clone; |
| 289 | } |
| 290 | |
| 291 | function shouldSetTextContent(type: string, props: Props): boolean { |
| 292 | if (type === 'errorInBeginPhase') { |
no test coverage detected