@@ -38,25 +38,26 @@ export function attr_effect(dom, attribute, value) {
38
38
export function attr ( dom , attribute , value ) {
39
39
value = value == null ? null : value + '' ;
40
40
41
+ // @ts -expect-error
41
42
var attributes = ( dom . __attributes ??= { } ) ;
42
43
43
44
if ( hydrating ) {
44
45
attributes [ attribute ] = dom . getAttribute ( attribute ) ;
45
- }
46
46
47
- if ( attributes [ attribute ] === ( attributes [ attribute ] = value ) ) return ;
47
+ if ( attribute === 'src' || attribute === 'href' || attribute === 'srcset' ) {
48
+ if ( DEV ) {
49
+ check_src_in_dev_hydration ( dom , attribute , value ) ;
50
+ }
48
51
49
- if ( DEV ) {
50
- check_src_in_dev_hydration ( dom , attribute , value ) ;
52
+ // If we reset these attributes, they would result in another network request, which we want to avoid.
53
+ // We assume they are the same between client and server as checking if they are equal is expensive
54
+ // (we can't just compare the strings as they can be different between client and server but result in the
55
+ // same url, so we would need to create hidden anchor elements to compare them)
56
+ return ;
57
+ }
51
58
}
52
59
53
- if ( hydrating && ( attribute === 'src' || attribute === 'href' || attribute === 'srcset' ) ) {
54
- // If we reset these attributes, they would result in another network request, which we want to avoid.
55
- // We assume they are the same between client and server as checking if they are equal is expensive
56
- // (we can't just compare the strings as they can be different between client and server but result in the
57
- // same url, so we would need to create hidden anchor elements to compare them)
58
- return ;
59
- }
60
+ if ( attributes [ attribute ] === ( attributes [ attribute ] = value ) ) return ;
60
61
61
62
if ( value === null ) {
62
63
dom . removeAttribute ( attribute ) ;
0 commit comments