@@ -239,6 +239,16 @@ const createVNodeWithArgsTransform = (
239
239
240
240
export const InternalObjectKey = `__vInternal`
241
241
242
+ const normalizeKey = ( { key } : VNodeProps ) : VNode [ 'key' ] =>
243
+ key != null ? key : null
244
+
245
+ const normalizeRef = ( { ref } : VNodeProps ) : VNode [ 'ref' ] =>
246
+ ( ref != null
247
+ ? isArray ( ref )
248
+ ? ref
249
+ : [ currentRenderingInstance ! , ref ]
250
+ : null ) as any
251
+
242
252
export const createVNode = ( __DEV__
243
253
? createVNodeWithArgsTransform
244
254
: _createVNode ) as typeof _createVNode
@@ -312,11 +322,8 @@ function _createVNode(
312
322
_isVNode : true ,
313
323
type,
314
324
props,
315
- key : props && props . key != null ? props . key : null ,
316
- ref :
317
- props && props . ref != null
318
- ? [ currentRenderingInstance ! , props . ref ]
319
- : null ,
325
+ key : props && normalizeKey ( props ) ,
326
+ ref : props && normalizeRef ( props ) ,
320
327
scopeId : currentScopeId ,
321
328
children : null ,
322
329
component : null ,
@@ -373,13 +380,8 @@ export function cloneVNode<T, U>(
373
380
_isVNode : true ,
374
381
type : vnode . type ,
375
382
props,
376
- key : props && props . key != null ? props . key : null ,
377
- ref :
378
- props && props . ref != null
379
- ? isArray ( props . ref )
380
- ? props . ref
381
- : [ currentRenderingInstance ! , props . ref ]
382
- : null ,
383
+ key : props && normalizeKey ( props ) ,
384
+ ref : props && normalizeRef ( props ) ,
383
385
scopeId : vnode . scopeId ,
384
386
children : vnode . children ,
385
387
target : vnode . target ,
0 commit comments