File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,17 @@ export const initializeClientHydrate = (
279279 const rnLen = shadowRootNodes . length ;
280280 if ( rnLen ) {
281281 for ( rnIdex ; rnIdex < rnLen ; rnIdex ++ ) {
282- shadowRoot . appendChild ( shadowRootNodes [ rnIdex ] ) ;
282+ const node = shadowRootNodes [ rnIdex ] ;
283+
284+ /**
285+ * in apps with a lot of components the `shadowRootNodes` array can be modified while iterating over it
286+ * so we need to check if the node is still in the array before appending it to avoid any errors like:
287+ *
288+ * TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
289+ */
290+ if ( node ) {
291+ shadowRoot . appendChild ( node ) ;
292+ }
283293 }
284294
285295 Array . from ( hostElm . childNodes ) . forEach ( ( node ) => {
You can’t perform that action at this time.
0 commit comments