Skip to content

Commit edf31f1

Browse files
committed
naming things
1 parent cea622a commit edf31f1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/svelte/src/internal/client/dom/blocks/svelte-html.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { hydrating } from '../hydration.js';
99
*/
1010
export function svelte_html(get_attributes) {
1111
const node = document.documentElement;
12-
const own = {};
12+
const self = {};
1313

14-
/** @type {Record<string, Array<[any, any]>>} to check who set the last value of each attribute */
14+
/** @type {Record<string, Array<{ owner: any, value: any }>>} to check who set the last value of each attribute */
1515
// @ts-expect-error
1616
const current_setters = (node.__attributes_setters ??= {});
1717

@@ -23,11 +23,11 @@ export function svelte_html(get_attributes) {
2323

2424
for (const name in attributes) {
2525
const current = (current_setters[name] ??= []);
26-
const index = current.findIndex(([owner]) => owner === own);
27-
const old = index === -1 ? null : current.splice(index, 1)[0][1];
26+
const index = current.findIndex((c) => c.owner === self);
27+
const old = index === -1 ? null : current.splice(index, 1)[0].value;
2828

2929
let value = attributes[name];
30-
current.push([own, value]);
30+
current.push({ owner: self, value });
3131

3232
// Do nothing on initial render during hydration: If there are attribute duplicates, the last value
3333
// wins, which could result in needless hydration repairs from earlier values.
@@ -36,7 +36,7 @@ export function svelte_html(get_attributes) {
3636
if (name === 'class') {
3737
// Avoid unrelated attribute changes from triggering class changes
3838
if (old !== value) {
39-
set_class(node, current_setters[name].map(([_, text]) => text).join(' '));
39+
set_class(node, current_setters[name].map((e) => e.value).join(' '));
4040
}
4141
} else {
4242
set_attribute(node, name, value);
@@ -47,15 +47,15 @@ export function svelte_html(get_attributes) {
4747
teardown(() => {
4848
for (const name in attributes) {
4949
const old = current_setters[name];
50-
current_setters[name] = old.filter(([owner]) => owner !== own);
50+
current_setters[name] = old.filter((o) => o.owner !== self);
5151
const current = current_setters[name];
5252

5353
if (name === 'class') {
54-
set_class(node, current.map(([_, text]) => text).join(' '));
54+
set_class(node, current.map((c) => c.value).join(' '));
5555

5656
// If this was the last one setting this attribute, revert to the previous value
57-
} else if (old[old.length - 1][0] === own) {
58-
set_attribute(node, name, current[current.length - 1]?.[1]);
57+
} else if (old[old.length - 1].owner === self) {
58+
set_attribute(node, name, current[current.length - 1]?.value);
5959
}
6060
}
6161
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy