Skip to content

chore: rename internal object properties #9532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-ads-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: rename internal object properties
185 changes: 121 additions & 64 deletions packages/svelte/src/internal/client/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,87 +12,123 @@ export const DYNAMIC_ELEMENT_BLOCK = 8;
export const SNIPPET_BLOCK = 9;

/**
* @param {Node} container
* @param {boolean} intro
* @returns {import('./types.js').RootBlock}
*/
export function create_root_block(container, intro) {
export function create_root_block(intro) {
return {
dom: null,
effect: null,
container,
intro,
parent: null,
transition: null,
type: ROOT_BLOCK
// dom
d: null,
// effect
e: null,
// intro
i: intro,
// parent
p: null,
// transition
r: null,
// type
t: ROOT_BLOCK
};
}

/** @returns {import('./types.js').IfBlock} */
export function create_if_block() {
return {
current: false,
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
type: IF_BLOCK
// current
c: false,
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// type
t: IF_BLOCK
};
}

/** @returns {import('./types.js').KeyBlock} */
export function create_key_block() {
return {
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
type: KEY_BLOCK
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// type
t: KEY_BLOCK
};
}

/** @returns {import('./types.js').HeadBlock} */
export function create_head_block() {
return {
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
type: HEAD_BLOCK
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// type
t: HEAD_BLOCK
};
}

/** @returns {import('./types.js').DynamicElementBlock} */
export function create_dynamic_element_block() {
return {
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
type: DYNAMIC_ELEMENT_BLOCK
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// type
t: DYNAMIC_ELEMENT_BLOCK
};
}

/** @returns {import('./types.js').DynamicComponentBlock} */
export function create_dynamic_component_block() {
return {
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
type: DYNAMIC_COMPONENT_BLOCK
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// type
t: DYNAMIC_COMPONENT_BLOCK
};
}

/** @returns {import('./types.js').AwaitBlock} */
export function create_await_block() {
return {
dom: null,
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
pending: true,
transition: null,
type: AWAIT_BLOCK
// dom
d: null,
// effect
e: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// pending
n: true,
// transition
r: null,
// type
t: AWAIT_BLOCK
};
}

Expand All @@ -103,15 +139,23 @@ export function create_await_block() {
*/
export function create_each_block(flags, anchor) {
return {
anchor,
dom: null,
flags,
items: [],
effect: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
transition: null,
transitions: [],
type: EACH_BLOCK
// anchor
a: anchor,
// dom
d: null,
// flags
f: flags,
// items
v: [],
// effect
e: null,
p: /** @type {import('./types.js').Block} */ (current_block),
// transition
r: null,
// transitions
s: [],
// type
t: EACH_BLOCK
};
}

Expand All @@ -123,25 +167,38 @@ export function create_each_block(flags, anchor) {
*/
export function create_each_item_block(item, index, key) {
return {
dom: null,
effect: null,
index,
key,
item,
parent: /** @type {import('./types.js').EachBlock} */ (current_block),
transition: null,
transitions: null,
type: EACH_ITEM_BLOCK
// dom
d: null,
// effect
e: null,
i: index,
// key
k: key,
// item
v: item,
// parent
p: /** @type {import('./types.js').EachBlock} */ (current_block),
// transition
r: null,
// transitions
s: null,
// type
t: EACH_ITEM_BLOCK
};
}

/** @returns {import('./types.js').SnippetBlock} */
export function create_snippet_block() {
return {
dom: null,
parent: /** @type {import('./types.js').Block} */ (current_block),
effect: null,
transition: null,
type: SNIPPET_BLOCK
// dom
d: null,
// parent
p: /** @type {import('./types.js').Block} */ (current_block),
// effect
e: null,
// transition
r: null,
// type
t: SNIPPET_BLOCK
};
}
26 changes: 13 additions & 13 deletions packages/svelte/src/internal/client/reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function reconcile_html(dom, value, svg) {
* @returns {Text | Element | Comment}
*/
function insert_each_item_block(block, dom, is_controlled, sibling) {
var current = /** @type {import('./types.js').TemplateNode} */ (block.dom);
var current = /** @type {import('./types.js').TemplateNode} */ (block.d);
if (sibling === null) {
if (is_controlled) {
return insert(current, /** @type {Element} */ (dom), null);
Expand All @@ -128,7 +128,7 @@ function insert_each_item_block(block, dom, is_controlled, sibling) {
* @returns {Text | Element | Comment}
*/
function get_first_child(block) {
var current = block.dom;
var current = block.d;
if (is_array(current)) {
return /** @type {Text | Element | Comment} */ (current[0]);
}
Expand All @@ -147,9 +147,9 @@ function destroy_active_transition_blocks(active_transitions) {
var transition;
for (; i < length; i++) {
block = active_transitions[i];
transition = block.transition;
transition = block.r;
if (transition !== null) {
block.transition = null;
block.r = null;
destroy_each_item_block(block, null, false);
}
}
Expand Down Expand Up @@ -177,8 +177,8 @@ export function reconcile_indexed_array(
flags,
apply_transitions
) {
var a_blocks = each_block.items;
var active_transitions = each_block.transitions;
var a_blocks = each_block.v;
var active_transitions = each_block.s;

/** @type {number | void} */
var a = a_blocks.length;
Expand Down Expand Up @@ -245,7 +245,7 @@ export function reconcile_indexed_array(
}
}
}
each_block.items = b_blocks;
each_block.v = b_blocks;
}
// Reconcile arrays by the equality of the elements in the array. This algorithm
// is based on Ivi's reconcilation logic:
Expand Down Expand Up @@ -275,9 +275,9 @@ export function reconcile_tracked_array(
apply_transitions,
keys
) {
var a_blocks = each_block.items;
var a_blocks = each_block.v;
const is_computed_key = keys !== null;
var active_transitions = each_block.transitions;
var active_transitions = each_block.s;

/** @type {number | void} */
var a = a_blocks.length;
Expand Down Expand Up @@ -352,7 +352,7 @@ export function reconcile_tracked_array(
// Step 1
outer: while (true) {
// From the end
while (a_blocks[a_end].key === key) {
while (a_blocks[a_end].k === key) {
block = a_blocks[a_end--];
item = array[b_end];
if (should_update_block) {
Expand All @@ -368,7 +368,7 @@ export function reconcile_tracked_array(
item = array[start];
key = is_computed_key ? keys[start] : item;
// At the start
while (start <= a_end && start <= b_end && a_blocks[start].key === key) {
while (start <= a_end && start <= b_end && a_blocks[start].k === key) {
item = array[start];
block = a_blocks[start];
if (should_update_block) {
Expand Down Expand Up @@ -410,7 +410,7 @@ export function reconcile_tracked_array(
map_set(item_index, key, a);
}
for (b = start; b <= a_end; ++b) {
a = map_get(item_index, /** @type {V} */ (a_blocks[b].key));
a = map_get(item_index, /** @type {V} */ (a_blocks[b].k));
block = a_blocks[b];
if (a !== undefined) {
pos = pos < a ? a : MOVED_BLOCK;
Expand Down Expand Up @@ -464,7 +464,7 @@ export function reconcile_tracked_array(
}
}
}
each_block.items = b_blocks;
each_block.v = b_blocks;
}
// Longest Increased Subsequence algorithm.

Expand Down
Loading