Skip to content

Commit 5809ac6

Browse files
authored
chore: rename internal object properties (#9532)
* chore: rename internal object properties chore: rename internal object properties order properties and add comments add missing remove_in_transitions * jsdoc
1 parent 5458ea7 commit 5809ac6

File tree

9 files changed

+629
-500
lines changed

9 files changed

+629
-500
lines changed

.changeset/early-ads-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: rename internal object properties

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

Lines changed: 121 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,87 +12,123 @@ export const DYNAMIC_ELEMENT_BLOCK = 8;
1212
export const SNIPPET_BLOCK = 9;
1313

1414
/**
15-
* @param {Node} container
1615
* @param {boolean} intro
1716
* @returns {import('./types.js').RootBlock}
1817
*/
19-
export function create_root_block(container, intro) {
18+
export function create_root_block(intro) {
2019
return {
21-
dom: null,
22-
effect: null,
23-
container,
24-
intro,
25-
parent: null,
26-
transition: null,
27-
type: ROOT_BLOCK
20+
// dom
21+
d: null,
22+
// effect
23+
e: null,
24+
// intro
25+
i: intro,
26+
// parent
27+
p: null,
28+
// transition
29+
r: null,
30+
// type
31+
t: ROOT_BLOCK
2832
};
2933
}
3034

3135
/** @returns {import('./types.js').IfBlock} */
3236
export function create_if_block() {
3337
return {
34-
current: false,
35-
dom: null,
36-
effect: null,
37-
parent: /** @type {import('./types.js').Block} */ (current_block),
38-
transition: null,
39-
type: IF_BLOCK
38+
// current
39+
c: false,
40+
// dom
41+
d: null,
42+
// effect
43+
e: null,
44+
// parent
45+
p: /** @type {import('./types.js').Block} */ (current_block),
46+
// transition
47+
r: null,
48+
// type
49+
t: IF_BLOCK
4050
};
4151
}
4252

4353
/** @returns {import('./types.js').KeyBlock} */
4454
export function create_key_block() {
4555
return {
46-
dom: null,
47-
effect: null,
48-
parent: /** @type {import('./types.js').Block} */ (current_block),
49-
transition: null,
50-
type: KEY_BLOCK
56+
// dom
57+
d: null,
58+
// effect
59+
e: null,
60+
// parent
61+
p: /** @type {import('./types.js').Block} */ (current_block),
62+
// transition
63+
r: null,
64+
// type
65+
t: KEY_BLOCK
5166
};
5267
}
5368

5469
/** @returns {import('./types.js').HeadBlock} */
5570
export function create_head_block() {
5671
return {
57-
dom: null,
58-
effect: null,
59-
parent: /** @type {import('./types.js').Block} */ (current_block),
60-
transition: null,
61-
type: HEAD_BLOCK
72+
// dom
73+
d: null,
74+
// effect
75+
e: null,
76+
// parent
77+
p: /** @type {import('./types.js').Block} */ (current_block),
78+
// transition
79+
r: null,
80+
// type
81+
t: HEAD_BLOCK
6282
};
6383
}
6484

6585
/** @returns {import('./types.js').DynamicElementBlock} */
6686
export function create_dynamic_element_block() {
6787
return {
68-
dom: null,
69-
effect: null,
70-
parent: /** @type {import('./types.js').Block} */ (current_block),
71-
transition: null,
72-
type: DYNAMIC_ELEMENT_BLOCK
88+
// dom
89+
d: null,
90+
// effect
91+
e: null,
92+
// parent
93+
p: /** @type {import('./types.js').Block} */ (current_block),
94+
// transition
95+
r: null,
96+
// type
97+
t: DYNAMIC_ELEMENT_BLOCK
7398
};
7499
}
75100

76101
/** @returns {import('./types.js').DynamicComponentBlock} */
77102
export function create_dynamic_component_block() {
78103
return {
79-
dom: null,
80-
effect: null,
81-
parent: /** @type {import('./types.js').Block} */ (current_block),
82-
transition: null,
83-
type: DYNAMIC_COMPONENT_BLOCK
104+
// dom
105+
d: null,
106+
// effect
107+
e: null,
108+
// parent
109+
p: /** @type {import('./types.js').Block} */ (current_block),
110+
// transition
111+
r: null,
112+
// type
113+
t: DYNAMIC_COMPONENT_BLOCK
84114
};
85115
}
86116

87117
/** @returns {import('./types.js').AwaitBlock} */
88118
export function create_await_block() {
89119
return {
90-
dom: null,
91-
effect: null,
92-
parent: /** @type {import('./types.js').Block} */ (current_block),
93-
pending: true,
94-
transition: null,
95-
type: AWAIT_BLOCK
120+
// dom
121+
d: null,
122+
// effect
123+
e: null,
124+
// parent
125+
p: /** @type {import('./types.js').Block} */ (current_block),
126+
// pending
127+
n: true,
128+
// transition
129+
r: null,
130+
// type
131+
t: AWAIT_BLOCK
96132
};
97133
}
98134

@@ -103,15 +139,23 @@ export function create_await_block() {
103139
*/
104140
export function create_each_block(flags, anchor) {
105141
return {
106-
anchor,
107-
dom: null,
108-
flags,
109-
items: [],
110-
effect: null,
111-
parent: /** @type {import('./types.js').Block} */ (current_block),
112-
transition: null,
113-
transitions: [],
114-
type: EACH_BLOCK
142+
// anchor
143+
a: anchor,
144+
// dom
145+
d: null,
146+
// flags
147+
f: flags,
148+
// items
149+
v: [],
150+
// effect
151+
e: null,
152+
p: /** @type {import('./types.js').Block} */ (current_block),
153+
// transition
154+
r: null,
155+
// transitions
156+
s: [],
157+
// type
158+
t: EACH_BLOCK
115159
};
116160
}
117161

@@ -123,25 +167,38 @@ export function create_each_block(flags, anchor) {
123167
*/
124168
export function create_each_item_block(item, index, key) {
125169
return {
126-
dom: null,
127-
effect: null,
128-
index,
129-
key,
130-
item,
131-
parent: /** @type {import('./types.js').EachBlock} */ (current_block),
132-
transition: null,
133-
transitions: null,
134-
type: EACH_ITEM_BLOCK
170+
// dom
171+
d: null,
172+
// effect
173+
e: null,
174+
i: index,
175+
// key
176+
k: key,
177+
// item
178+
v: item,
179+
// parent
180+
p: /** @type {import('./types.js').EachBlock} */ (current_block),
181+
// transition
182+
r: null,
183+
// transitions
184+
s: null,
185+
// type
186+
t: EACH_ITEM_BLOCK
135187
};
136188
}
137189

138190
/** @returns {import('./types.js').SnippetBlock} */
139191
export function create_snippet_block() {
140192
return {
141-
dom: null,
142-
parent: /** @type {import('./types.js').Block} */ (current_block),
143-
effect: null,
144-
transition: null,
145-
type: SNIPPET_BLOCK
193+
// dom
194+
d: null,
195+
// parent
196+
p: /** @type {import('./types.js').Block} */ (current_block),
197+
// effect
198+
e: null,
199+
// transition
200+
r: null,
201+
// type
202+
t: SNIPPET_BLOCK
146203
};
147204
}

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function reconcile_html(dom, value, svg) {
112112
* @returns {Text | Element | Comment}
113113
*/
114114
function insert_each_item_block(block, dom, is_controlled, sibling) {
115-
var current = /** @type {import('./types.js').TemplateNode} */ (block.dom);
115+
var current = /** @type {import('./types.js').TemplateNode} */ (block.d);
116116
if (sibling === null) {
117117
if (is_controlled) {
118118
return insert(current, /** @type {Element} */ (dom), null);
@@ -128,7 +128,7 @@ function insert_each_item_block(block, dom, is_controlled, sibling) {
128128
* @returns {Text | Element | Comment}
129129
*/
130130
function get_first_child(block) {
131-
var current = block.dom;
131+
var current = block.d;
132132
if (is_array(current)) {
133133
return /** @type {Text | Element | Comment} */ (current[0]);
134134
}
@@ -147,9 +147,9 @@ function destroy_active_transition_blocks(active_transitions) {
147147
var transition;
148148
for (; i < length; i++) {
149149
block = active_transitions[i];
150-
transition = block.transition;
150+
transition = block.r;
151151
if (transition !== null) {
152-
block.transition = null;
152+
block.r = null;
153153
destroy_each_item_block(block, null, false);
154154
}
155155
}
@@ -177,8 +177,8 @@ export function reconcile_indexed_array(
177177
flags,
178178
apply_transitions
179179
) {
180-
var a_blocks = each_block.items;
181-
var active_transitions = each_block.transitions;
180+
var a_blocks = each_block.v;
181+
var active_transitions = each_block.s;
182182

183183
/** @type {number | void} */
184184
var a = a_blocks.length;
@@ -245,7 +245,7 @@ export function reconcile_indexed_array(
245245
}
246246
}
247247
}
248-
each_block.items = b_blocks;
248+
each_block.v = b_blocks;
249249
}
250250
// Reconcile arrays by the equality of the elements in the array. This algorithm
251251
// is based on Ivi's reconcilation logic:
@@ -275,9 +275,9 @@ export function reconcile_tracked_array(
275275
apply_transitions,
276276
keys
277277
) {
278-
var a_blocks = each_block.items;
278+
var a_blocks = each_block.v;
279279
const is_computed_key = keys !== null;
280-
var active_transitions = each_block.transitions;
280+
var active_transitions = each_block.s;
281281

282282
/** @type {number | void} */
283283
var a = a_blocks.length;
@@ -352,7 +352,7 @@ export function reconcile_tracked_array(
352352
// Step 1
353353
outer: while (true) {
354354
// From the end
355-
while (a_blocks[a_end].key === key) {
355+
while (a_blocks[a_end].k === key) {
356356
block = a_blocks[a_end--];
357357
item = array[b_end];
358358
if (should_update_block) {
@@ -368,7 +368,7 @@ export function reconcile_tracked_array(
368368
item = array[start];
369369
key = is_computed_key ? keys[start] : item;
370370
// At the start
371-
while (start <= a_end && start <= b_end && a_blocks[start].key === key) {
371+
while (start <= a_end && start <= b_end && a_blocks[start].k === key) {
372372
item = array[start];
373373
block = a_blocks[start];
374374
if (should_update_block) {
@@ -410,7 +410,7 @@ export function reconcile_tracked_array(
410410
map_set(item_index, key, a);
411411
}
412412
for (b = start; b <= a_end; ++b) {
413-
a = map_get(item_index, /** @type {V} */ (a_blocks[b].key));
413+
a = map_get(item_index, /** @type {V} */ (a_blocks[b].k));
414414
block = a_blocks[b];
415415
if (a !== undefined) {
416416
pos = pos < a ? a : MOVED_BLOCK;
@@ -464,7 +464,7 @@ export function reconcile_tracked_array(
464464
}
465465
}
466466
}
467-
each_block.items = b_blocks;
467+
each_block.v = b_blocks;
468468
}
469469
// Longest Increased Subsequence algorithm.
470470

0 commit comments

Comments
 (0)