@@ -5,7 +5,7 @@ import { AutoComponentDescriptor, ComponentDescriptor, ServerComponentDescriptor
55import { isInteractiveRootComponentElement } from '../BrowserRenderer' ;
66import { applyAnyDeferredValue } from '../DomSpecialPropertyUtil' ;
77import { LogicalElement , getLogicalChildrenArray , getLogicalNextSibling , getLogicalParent , getLogicalRootDescriptor , insertLogicalChild , insertLogicalChildBefore , isLogicalElement , toLogicalElement , toLogicalRootCommentElement } from '../LogicalElements' ;
8- import { synchronizeAttributes } from './AttributeSync' ;
8+ import { attributeSetsAreIdentical , synchronizeAttributes } from './AttributeSync' ;
99import { cannotMergeDueToDataPermanentAttributes , isDataPermanentElement } from './DataPermanentElementSync' ;
1010import { UpdateCost , ItemList , Operation , computeEditScript } from './EditScript' ;
1111
@@ -308,8 +308,15 @@ function domNodeComparer(a: Node, b: Node): UpdateCost {
308308 return UpdateCost . Infinite ;
309309 }
310310
311- // Always treat "preloads" as new elements.
312- if ( isPreloadElement ( a as Element ) || isPreloadElement ( b as Element ) ) {
311+ // If both elements are the same preload (based on all attributes), we need to match them and do nothing;
312+ // Otherwise, browser would trigger a new preload request.
313+ // If attributes don't match, we can't simply update the element, because browser could trigger
314+ // an invalid preload request based on attribute order.
315+ const aIsPreload = isPreloadElement ( a as Element ) ;
316+ const bIsPreload = isPreloadElement ( b as Element ) ;
317+ if ( aIsPreload && bIsPreload && attributeSetsAreIdentical ( ( a as Element ) . attributes , ( b as Element ) . attributes ) ) {
318+ return UpdateCost . None ;
319+ } else if ( aIsPreload || bIsPreload ) {
313320 return UpdateCost . Infinite ;
314321 }
315322
0 commit comments