Skip to content

Commit df7071c

Browse files
committed
dom -> element
1 parent c984385 commit df7071c

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ export function attr_effect(dom, attribute, value) {
3131
}
3232

3333
/**
34-
* @param {Element} dom
34+
* @param {Element} element
3535
* @param {string} attribute
3636
* @param {string | null} value
3737
*/
38-
export function attr(dom, attribute, value) {
38+
export function attr(element, attribute, value) {
3939
value = value == null ? null : value + '';
4040

4141
// @ts-expect-error
42-
var attributes = (dom.__attributes ??= {});
42+
var attributes = (element.__attributes ??= {});
4343

4444
if (hydrating) {
45-
attributes[attribute] = dom.getAttribute(attribute);
45+
attributes[attribute] = element.getAttribute(attribute);
4646

4747
if (attribute === 'src' || attribute === 'href' || attribute === 'srcset') {
48-
check_src_in_dev_hydration(dom, attribute, value);
48+
check_src_in_dev_hydration(element, attribute, value);
4949

5050
// If we reset these attributes, they would result in another network request, which we want to avoid.
5151
// We assume they are the same between client and server as checking if they are equal is expensive
@@ -58,9 +58,9 @@ export function attr(dom, attribute, value) {
5858
if (attributes[attribute] === (attributes[attribute] = value)) return;
5959

6060
if (value === null) {
61-
dom.removeAttribute(attribute);
61+
element.removeAttribute(attribute);
6262
} else {
63-
dom.setAttribute(attribute, value);
63+
element.setAttribute(attribute, value);
6464
}
6565
}
6666

@@ -126,14 +126,14 @@ export function spread_attributes_effect(dom, attrs, lowercase_attributes, css_h
126126

127127
/**
128128
* Spreads attributes onto a DOM element, taking into account the currently set attributes
129-
* @param {Element & ElementCSSInlineStyle} dom
129+
* @param {Element & ElementCSSInlineStyle} element
130130
* @param {Record<string, unknown> | undefined} prev
131131
* @param {Record<string, unknown>[]} attrs
132132
* @param {boolean} lowercase_attributes
133133
* @param {string} css_hash
134134
* @returns {Record<string, unknown>}
135135
*/
136-
export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_hash) {
136+
export function spread_attributes(element, prev, attrs, lowercase_attributes, css_hash) {
137137
var next = object_assign({}, ...attrs);
138138
var has_hash = css_hash.length !== 0;
139139

@@ -147,8 +147,8 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
147147
next.class = '';
148148
}
149149

150-
var setters = map_get(setters_cache, dom.nodeName);
151-
if (!setters) map_set(setters_cache, dom.nodeName, (setters = get_setters(dom)));
150+
var setters = map_get(setters_cache, element.nodeName);
151+
if (!setters) map_set(setters_cache, element.nodeName, (setters = get_setters(element)));
152152

153153
for (key in next) {
154154
var value = next[key];
@@ -173,27 +173,27 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
173173
}
174174

175175
if (!delegated && prev?.[key]) {
176-
dom.removeEventListener(event_name, /** @type {any} */ (prev[key]), opts);
176+
element.removeEventListener(event_name, /** @type {any} */ (prev[key]), opts);
177177
}
178178

179179
if (value != null) {
180180
if (!delegated) {
181-
dom.addEventListener(event_name, value, opts);
181+
element.addEventListener(event_name, value, opts);
182182
} else {
183183
// @ts-ignore
184-
dom[`__${event_name}`] = value;
184+
element[`__${event_name}`] = value;
185185
delegate([event_name]);
186186
}
187187
}
188188
} else if (value == null) {
189-
dom.removeAttribute(key);
189+
element.removeAttribute(key);
190190
} else if (key === 'style') {
191-
dom.style.cssText = value + '';
191+
element.style.cssText = value + '';
192192
} else if (key === 'autofocus') {
193-
autofocus(/** @type {HTMLElement} */ (dom), Boolean(value));
193+
autofocus(/** @type {HTMLElement} */ (element), Boolean(value));
194194
} else if (key === '__value' || key === 'value') {
195195
// @ts-ignore
196-
dom.value = dom[key] = dom.__value = value;
196+
element.value = element[key] = element.__value = value;
197197
} else {
198198
var name = key;
199199
if (lowercase_attributes) {
@@ -203,18 +203,18 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
203203

204204
if (setters.includes(name)) {
205205
if (hydrating && (name === 'src' || name === 'href' || name === 'srcset')) {
206-
check_src_in_dev_hydration(dom, name, value);
206+
check_src_in_dev_hydration(element, name, value);
207207
} else {
208208
// @ts-ignore
209-
dom[name] = value;
209+
element[name] = value;
210210
}
211211
} else if (typeof value !== 'function') {
212212
if (has_hash && name === 'class') {
213213
if (value) value += ' ';
214214
value += css_hash;
215215
}
216216

217-
attr(dom, name, value);
217+
attr(element, name, value);
218218
}
219219
}
220220
}
@@ -298,20 +298,20 @@ function get_setters(element) {
298298
}
299299

300300
/**
301-
* @param {any} dom
301+
* @param {any} element
302302
* @param {string} attribute
303303
* @param {string | null} value
304304
*/
305-
function check_src_in_dev_hydration(dom, attribute, value) {
305+
function check_src_in_dev_hydration(element, attribute, value) {
306306
if (!DEV) return;
307-
if (attribute === 'srcset' && srcset_url_equal(dom, value)) return;
308-
if (src_url_equal(dom.getAttribute(attribute) ?? '', value ?? '')) return;
307+
if (attribute === 'srcset' && srcset_url_equal(element, value)) return;
308+
if (src_url_equal(element.getAttribute(attribute) ?? '', value ?? '')) return;
309309

310310
// eslint-disable-next-line no-console
311311
console.error(
312312
`Detected a ${attribute} attribute value change during hydration. This will not be repaired during hydration, ` +
313313
`the ${attribute} value that came from the server will be used. Related element:`,
314-
dom,
314+
element,
315315
' Differing value:',
316316
value
317317
);

0 commit comments

Comments
 (0)