@@ -64,6 +64,9 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
64
64
/** @type {boolean } */
65
65
is_src ;
66
66
67
+ /** @type {boolean } */
68
+ is_srcset ;
69
+
67
70
/** @type {boolean } */
68
71
is_select_value_attribute ;
69
72
@@ -120,6 +123,9 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
120
123
this . is_src =
121
124
this . name === 'src' &&
122
125
( ! this . parent . node . namespace || this . parent . node . namespace === namespaces . html ) ;
126
+ this . is_srcset =
127
+ this . name === 'srcset' &&
128
+ ( ! this . parent . node . namespace || this . parent . node . namespace === namespaces . html ) ;
123
129
this . should_cache = should_cache ( this ) ;
124
130
}
125
131
@@ -164,6 +170,11 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
164
170
b `if (!@src_url_equal(${ element . var } .src, ${ init } )) ${ method } (${ element . var } , "${ name } ", ${ this . last } );`
165
171
) ;
166
172
updater = b `${ method } (${ element . var } , "${ name } ", ${ should_cache ? this . last : value } );` ;
173
+ } else if ( this . is_srcset ) {
174
+ block . chunks . hydrate . push (
175
+ b `if (!@srcset_url_equal(${ element . var } , ${ init } )) ${ method } (${ element . var } , "${ name } ", ${ this . last } );`
176
+ ) ;
177
+ updater = b `${ method } (${ element . var } , "${ name } ", ${ should_cache ? this . last : value } );` ;
167
178
} else if ( property_name ) {
168
179
block . chunks . hydrate . push ( b `${ element . var } .${ property_name } = ${ init } ;` ) ;
169
180
updater = block . renderer . options . dev
@@ -403,7 +414,7 @@ Object.keys(attribute_lookup).forEach((name) => {
403
414
404
415
/** @param {AttributeWrapper } attribute */
405
416
function should_cache ( attribute ) {
406
- return attribute . is_src || attribute . node . should_cache ( ) ;
417
+ return attribute . is_src || attribute . is_srcset || attribute . node . should_cache ( ) ;
407
418
}
408
419
const regex_contains_checked_or_group = / c h e c k e d | g r o u p / ;
409
420
0 commit comments