@@ -2532,6 +2532,7 @@ export function attr(dom, attribute, value) {
2532
2532
// (we can't just compare the strings as they can be different between client and server but result in the
2533
2533
// same url, so we would need to create hidden anchor elements to compare them)
2534
2534
attribute !== 'src' &&
2535
+ attribute !== 'href' &&
2535
2536
attribute !== 'srcset' )
2536
2537
) {
2537
2538
if ( value === null ) {
@@ -2566,13 +2567,13 @@ function split_srcset(srcset) {
2566
2567
}
2567
2568
2568
2569
/**
2569
- * @param {HTMLSourceElement | HTMLImageElement } element_srcset
2570
+ * @param {HTMLSourceElement | HTMLImageElement } element
2570
2571
* @param {string | undefined | null } srcset
2571
2572
* @returns {boolean }
2572
2573
*/
2573
- export function srcset_url_equal ( element_srcset , srcset ) {
2574
- const element_urls = split_srcset ( element_srcset . srcset ) ;
2575
- const urls = split_srcset ( srcset || '' ) ;
2574
+ export function srcset_url_equal ( element , srcset ) {
2575
+ const element_urls = split_srcset ( element . srcset ) ;
2576
+ const urls = split_srcset ( srcset ?? '' ) ;
2576
2577
2577
2578
return (
2578
2579
urls . length === element_urls . length &&
@@ -2595,22 +2596,20 @@ export function srcset_url_equal(element_srcset, srcset) {
2595
2596
* @param {string | null } value
2596
2597
*/
2597
2598
function check_src_in_dev_hydration ( dom , attribute , value ) {
2598
- if ( current_hydration_fragment !== null && ( attribute === 'src' || attribute === 'srcset' ) ) {
2599
- if (
2600
- ( attribute === 'src' && ! src_url_equal ( dom . getAttribute ( 'src' ) || '' , value || '' ) ) ||
2601
- ( attribute === 'srcset' &&
2602
- ! srcset_url_equal ( /** @type {HTMLImageElement | HTMLSourceElement } */ ( dom ) , value || '' ) )
2603
- ) {
2604
- // eslint-disable-next-line no-console
2605
- console . error (
2606
- 'Detected a src/srcset attribute value change during hydration. This will not be repaired during hydration, ' +
2607
- 'the src/srcset value that came from the server will be used. Related element:' ,
2608
- dom ,
2609
- ' Differing value:' ,
2610
- value
2611
- ) ;
2612
- }
2613
- }
2599
+ if ( ! current_hydration_fragment ) return ;
2600
+ if ( attribute !== 'src' && attribute !== 'href' && attribute !== 'srcset' ) return ;
2601
+
2602
+ if ( attribute === 'srcset' && srcset_url_equal ( dom , value ) ) return ;
2603
+ if ( src_url_equal ( dom . getAttribute ( attribute ) ?? '' , value ?? '' ) ) return ;
2604
+
2605
+ // eslint-disable-next-line no-console
2606
+ console . error (
2607
+ `Detected a ${ attribute } attribute value change during hydration. This will not be repaired during hydration, ` +
2608
+ `the ${ attribute } value that came from the server will be used. Related element:` ,
2609
+ dom ,
2610
+ ' Differing value:' ,
2611
+ value
2612
+ ) ;
2614
2613
}
2615
2614
2616
2615
/**
@@ -2778,7 +2777,7 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
2778
2777
if (
2779
2778
current_hydration_fragment === null ||
2780
2779
// @ts -ignore see attr method for an explanation of src/srcset
2781
- ( dom [ name ] !== value && name !== 'src' && name !== 'srcset' )
2780
+ ( dom [ name ] !== value && name !== 'src' && name !== 'href' && name !== ' srcset')
2782
2781
) {
2783
2782
// @ts -ignore
2784
2783
dom [ name ] = value ;
0 commit comments