Skip to content

Commit 43a082c

Browse files
committed
switch to symbol
1 parent d7d39ef commit 43a082c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/svelte/src/internal/client/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ export const EFFECT_TRANSPARENT = 1 << 14;
1717
export const LEGACY_DERIVED_PROP = 1 << 15;
1818

1919
export const STATE_SYMBOL = Symbol('$state');
20+
export const LOADING_ATTR_SYMBOL = Symbol('');

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { delegate } from './events.js';
66
import { autofocus } from './misc.js';
77
import { effect, effect_root } from '../../reactivity/effects.js';
88
import * as w from '../../warnings.js';
9+
import { LOADING_ATTR_SYMBOL } from '../../constants.js';
910

1011
/**
1112
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
@@ -53,7 +54,7 @@ export function set_attribute(element, attribute, value) {
5354

5455
if (attribute === 'loading') {
5556
// @ts-expect-error
56-
element.__loading = value;
57+
element[LOADING_ATTR_SYMBOL] = value;
5758
}
5859

5960
if (value === null) {
@@ -351,12 +352,12 @@ export function handle_lazy_img(element) {
351352
if (!hydrating && element.loading === 'lazy') {
352353
var src = element.src;
353354
// @ts-expect-error
354-
element.__loading = null;
355+
element[LOADING_ATTR_SYMBOL] = null;
355356
element.loading = 'eager';
356357
element.removeAttribute('src');
357358
requestAnimationFrame(() => {
358359
// @ts-expect-error
359-
if (element.__loading !== 'eager') {
360+
if (element[LOADING_ATTR_SYMBOL] !== 'eager') {
360361
element.loading = 'lazy';
361362
}
362363
element.src = src;

0 commit comments

Comments
 (0)