@@ -121,7 +121,7 @@ options[OptionsType.VNODE] = (vnode) => {
121121 if ( typeof vnode . type === "function" ) {
122122 if ( vnode . type === Partial ) {
123123 const props = vnode . props as PartialProps ;
124- const key = normalizeKey ( vnode . key ?? "" ) ;
124+ const key = normalizeKey ( vnode . key ) ;
125125 const mode = ! props . mode || props . mode === "replace"
126126 ? PartialMode . Replace
127127 : props . mode === "append"
@@ -165,11 +165,10 @@ options[OptionsType.ATTR] = (name, value) => {
165165
166166const PATCHED = new WeakSet < VNode > ( ) ;
167167
168- function normalizeKey ( key : string | number ) {
169- if ( typeof key === "number" ) {
170- key = key . toString ( ) ;
171- }
172- return key . replaceAll ( ":" , "_" ) ;
168+ function normalizeKey ( key : unknown ) : string {
169+ const value = key ?? "" ;
170+ const s = ( typeof value !== "string" ) ? String ( value ) : value ;
171+ return s . replaceAll ( ":" , "_" ) ;
173172}
174173
175174const oldDiff = options [ OptionsType . DIFF ] ;
@@ -204,7 +203,7 @@ options[OptionsType.DIFF] = (vnode) => {
204203 if ( island === undefined ) {
205204 // Not an island, but we might need to preserve keys
206205 if ( vnode . key !== undefined ) {
207- const key = normalizeKey ( vnode . key ?? "" ) ;
206+ const key = normalizeKey ( vnode . key ) ;
208207 const originalType = vnode . type ;
209208 vnode . type = ( props ) => {
210209 const child = h ( originalType , props ) ;
@@ -241,7 +240,7 @@ options[OptionsType.DIFF] = (vnode) => {
241240 const child = h ( originalType , props ) ;
242241 PATCHED . add ( child ) ;
243242
244- const key = normalizeKey ( vnode . key ?? "" ) ;
243+ const key = normalizeKey ( vnode . key ) ;
245244 return wrapWithMarker (
246245 child ,
247246 "island" ,
0 commit comments