Skip to content

Commit 650db08

Browse files
committed
tidy up
1 parent eb08c68 commit 650db08

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,26 @@ export function attr_effect(dom, attribute, value) {
3838
export function attr(dom, attribute, value) {
3939
value = value == null ? null : value + '';
4040

41+
// @ts-expect-error
4142
var attributes = (dom.__attributes ??= {});
4243

4344
if (hydrating) {
4445
attributes[attribute] = dom.getAttribute(attribute);
45-
}
4646

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+
}
4851

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+
}
5158
}
5259

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;
6061

6162
if (value === null) {
6263
dom.removeAttribute(attribute);

0 commit comments

Comments
 (0)