Skip to content

Commit c984385

Browse files
committed
simplify
1 parent 650db08 commit c984385

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export function attr(dom, attribute, value) {
4545
attributes[attribute] = dom.getAttribute(attribute);
4646

4747
if (attribute === 'src' || attribute === 'href' || attribute === 'srcset') {
48-
if (DEV) {
49-
check_src_in_dev_hydration(dom, attribute, value);
50-
}
48+
check_src_in_dev_hydration(dom, attribute, value);
5149

5250
// If we reset these attributes, they would result in another network request, which we want to avoid.
5351
// We assume they are the same between client and server as checking if they are equal is expensive
@@ -204,15 +202,9 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
204202
}
205203

206204
if (setters.includes(name)) {
207-
if (DEV) {
205+
if (hydrating && (name === 'src' || name === 'href' || name === 'srcset')) {
208206
check_src_in_dev_hydration(dom, name, value);
209-
}
210-
211-
if (
212-
!hydrating ||
213-
// @ts-ignore see attr method for an explanation of src/srcset
214-
(dom[name] !== value && name !== 'src' && name !== 'href' && name !== 'srcset')
215-
) {
207+
} else {
216208
// @ts-ignore
217209
dom[name] = value;
218210
}
@@ -311,9 +303,7 @@ function get_setters(element) {
311303
* @param {string | null} value
312304
*/
313305
function check_src_in_dev_hydration(dom, attribute, value) {
314-
if (!hydrating) return;
315-
if (attribute !== 'src' && attribute !== 'href' && attribute !== 'srcset') return;
316-
306+
if (!DEV) return;
317307
if (attribute === 'srcset' && srcset_url_equal(dom, value)) return;
318308
if (src_url_equal(dom.getAttribute(attribute) ?? '', value ?? '')) return;
319309

0 commit comments

Comments
 (0)