@@ -31,21 +31,21 @@ export function attr_effect(dom, attribute, value) {
31
31
}
32
32
33
33
/**
34
- * @param {Element } dom
34
+ * @param {Element } element
35
35
* @param {string } attribute
36
36
* @param {string | null } value
37
37
*/
38
- export function attr ( dom , attribute , value ) {
38
+ export function attr ( element , attribute , value ) {
39
39
value = value == null ? null : value + '' ;
40
40
41
41
// @ts -expect-error
42
- var attributes = ( dom . __attributes ??= { } ) ;
42
+ var attributes = ( element . __attributes ??= { } ) ;
43
43
44
44
if ( hydrating ) {
45
- attributes [ attribute ] = dom . getAttribute ( attribute ) ;
45
+ attributes [ attribute ] = element . getAttribute ( attribute ) ;
46
46
47
47
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 ) ;
49
49
50
50
// If we reset these attributes, they would result in another network request, which we want to avoid.
51
51
// 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) {
58
58
if ( attributes [ attribute ] === ( attributes [ attribute ] = value ) ) return ;
59
59
60
60
if ( value === null ) {
61
- dom . removeAttribute ( attribute ) ;
61
+ element . removeAttribute ( attribute ) ;
62
62
} else {
63
- dom . setAttribute ( attribute , value ) ;
63
+ element . setAttribute ( attribute , value ) ;
64
64
}
65
65
}
66
66
@@ -126,14 +126,14 @@ export function spread_attributes_effect(dom, attrs, lowercase_attributes, css_h
126
126
127
127
/**
128
128
* Spreads attributes onto a DOM element, taking into account the currently set attributes
129
- * @param {Element & ElementCSSInlineStyle } dom
129
+ * @param {Element & ElementCSSInlineStyle } element
130
130
* @param {Record<string, unknown> | undefined } prev
131
131
* @param {Record<string, unknown>[] } attrs
132
132
* @param {boolean } lowercase_attributes
133
133
* @param {string } css_hash
134
134
* @returns {Record<string, unknown> }
135
135
*/
136
- export function spread_attributes ( dom , prev , attrs , lowercase_attributes , css_hash ) {
136
+ export function spread_attributes ( element , prev , attrs , lowercase_attributes , css_hash ) {
137
137
var next = object_assign ( { } , ...attrs ) ;
138
138
var has_hash = css_hash . length !== 0 ;
139
139
@@ -147,8 +147,8 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
147
147
next . class = '' ;
148
148
}
149
149
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 ) ) ) ;
152
152
153
153
for ( key in next ) {
154
154
var value = next [ key ] ;
@@ -173,27 +173,27 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
173
173
}
174
174
175
175
if ( ! delegated && prev ?. [ key ] ) {
176
- dom . removeEventListener ( event_name , /** @type {any } */ ( prev [ key ] ) , opts ) ;
176
+ element . removeEventListener ( event_name , /** @type {any } */ ( prev [ key ] ) , opts ) ;
177
177
}
178
178
179
179
if ( value != null ) {
180
180
if ( ! delegated ) {
181
- dom . addEventListener ( event_name , value , opts ) ;
181
+ element . addEventListener ( event_name , value , opts ) ;
182
182
} else {
183
183
// @ts -ignore
184
- dom [ `__${ event_name } ` ] = value ;
184
+ element [ `__${ event_name } ` ] = value ;
185
185
delegate ( [ event_name ] ) ;
186
186
}
187
187
}
188
188
} else if ( value == null ) {
189
- dom . removeAttribute ( key ) ;
189
+ element . removeAttribute ( key ) ;
190
190
} else if ( key === 'style' ) {
191
- dom . style . cssText = value + '' ;
191
+ element . style . cssText = value + '' ;
192
192
} else if ( key === 'autofocus' ) {
193
- autofocus ( /** @type {HTMLElement } */ ( dom ) , Boolean ( value ) ) ;
193
+ autofocus ( /** @type {HTMLElement } */ ( element ) , Boolean ( value ) ) ;
194
194
} else if ( key === '__value' || key === 'value' ) {
195
195
// @ts -ignore
196
- dom . value = dom [ key ] = dom . __value = value ;
196
+ element . value = element [ key ] = element . __value = value ;
197
197
} else {
198
198
var name = key ;
199
199
if ( lowercase_attributes ) {
@@ -203,18 +203,18 @@ export function spread_attributes(dom, prev, attrs, lowercase_attributes, css_ha
203
203
204
204
if ( setters . includes ( name ) ) {
205
205
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 ) ;
207
207
} else {
208
208
// @ts -ignore
209
- dom [ name ] = value ;
209
+ element [ name ] = value ;
210
210
}
211
211
} else if ( typeof value !== 'function' ) {
212
212
if ( has_hash && name === 'class' ) {
213
213
if ( value ) value += ' ' ;
214
214
value += css_hash ;
215
215
}
216
216
217
- attr ( dom , name , value ) ;
217
+ attr ( element , name , value ) ;
218
218
}
219
219
}
220
220
}
@@ -298,20 +298,20 @@ function get_setters(element) {
298
298
}
299
299
300
300
/**
301
- * @param {any } dom
301
+ * @param {any } element
302
302
* @param {string } attribute
303
303
* @param {string | null } value
304
304
*/
305
- function check_src_in_dev_hydration ( dom , attribute , value ) {
305
+ function check_src_in_dev_hydration ( element , attribute , value ) {
306
306
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 ;
309
309
310
310
// eslint-disable-next-line no-console
311
311
console . error (
312
312
`Detected a ${ attribute } attribute value change during hydration. This will not be repaired during hydration, ` +
313
313
`the ${ attribute } value that came from the server will be used. Related element:` ,
314
- dom ,
314
+ element ,
315
315
' Differing value:' ,
316
316
value
317
317
) ;
0 commit comments