i guess there's more client code besides just runtime.js

rm-bytes
Ben McCann 2 years ago
parent 72b32640e2
commit 87ac2a8f7f

@ -74,8 +74,8 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
transition.f(() => { transition.f(() => {
transitions.delete(transition); transitions.delete(transition);
if (transitions.size === 0) { if (transitions.size === 0) {
if (fallback.e !== null) { if (fallback.e) {
if (fallback.d !== null) { if (fallback.d) {
remove(fallback.d); remove(fallback.d);
fallback.d = null; fallback.d = null;
} }
@ -98,7 +98,7 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
const effect = render_effect( const effect = render_effect(
() => { () => {
const dom = block.d; const dom = block.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
block.d = null; block.d = null;
} }
@ -136,24 +136,24 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
: maybe_array == null : maybe_array == null
? [] ? []
: Array.from(maybe_array); : Array.from(maybe_array);
if (key_fn !== null) { if (key_fn) {
keys = array.map(key_fn); keys = array.map(key_fn);
} else if ((flags & EACH_KEYED) === 0) { } else if ((flags & EACH_KEYED) === 0) {
array.map(no_op); array.map(no_op);
} }
const length = array.length; const length = array.length;
if (fallback_fn !== null) { if (fallback_fn) {
if (length === 0) { if (length === 0) {
if (block.v.length !== 0 || render === null) { if (block.v.length !== 0 || !render) {
clear_each(block); clear_each(block);
create_fallback_effect(); create_fallback_effect();
return; return;
} }
} else if (block.v.length === 0 && current_fallback !== null) { } else if (block.v.length === 0 && current_fallback) {
const fallback = current_fallback; const fallback = current_fallback;
const transitions = fallback.s; const transitions = fallback.s;
if (transitions.size === 0) { if (transitions.size === 0) {
if (fallback.d !== null) { if (fallback.d) {
remove(fallback.d); remove(fallback.d);
fallback.d = null; fallback.d = null;
} }
@ -162,7 +162,7 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
} }
} }
} }
if (render !== null) { if (render) {
execute_effect(render); execute_effect(render);
} }
}, },
@ -177,13 +177,13 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
const anchor_node = block.a; const anchor_node = block.a;
const is_controlled = (flags & EACH_IS_CONTROLLED) !== 0; const is_controlled = (flags & EACH_IS_CONTROLLED) !== 0;
let fallback = current_fallback; let fallback = current_fallback;
while (fallback !== null) { while (fallback) {
const dom = fallback.d; const dom = fallback.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
} }
const effect = fallback.e; const effect = fallback.e;
if (effect !== null) { if (effect) {
destroy_signal(effect); destroy_signal(effect);
} }
fallback = fallback.p; fallback = fallback.p;
@ -280,7 +280,7 @@ function reconcile_indexed_array(
} else { } else {
var item; var item;
b_blocks = Array(b); b_blocks = Array(b);
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
/** @type {Node} */ /** @type {Node} */
var hydrating_node = current_hydration_fragment[0]; var hydrating_node = current_hydration_fragment[0];
for (; index < length; index++) { for (; index < length; index++) {
@ -350,7 +350,7 @@ function reconcile_tracked_array(
keys keys
) { ) {
var a_blocks = each_block.v; var a_blocks = each_block.v;
const is_computed_key = keys !== null; const is_computed_key = !!keys;
var active_transitions = each_block.s; var active_transitions = each_block.s;
/** @type {number | void} */ /** @type {number | void} */
@ -384,7 +384,7 @@ function reconcile_tracked_array(
var item; var item;
var idx; var idx;
b_blocks = Array(b); b_blocks = Array(b);
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
var fragment; var fragment;
/** @type {Node} */ /** @type {Node} */
@ -469,7 +469,7 @@ function reconcile_tracked_array(
} else if (start > b_end) { } else if (start > b_end) {
b = start; b = start;
do { do {
if ((block = a_blocks[b++]) !== null) { if ((block = a_blocks[b++])) {
destroy_each_item_block(block, active_transitions, apply_transitions); destroy_each_item_block(block, active_transitions, apply_transitions);
} }
} while (b <= a_end); } while (b <= a_end);
@ -493,7 +493,7 @@ function reconcile_tracked_array(
pos = pos < a ? a : MOVED_BLOCK; pos = pos < a ? a : MOVED_BLOCK;
sources[a - start] = b; sources[a - start] = b;
b_blocks[a] = block; b_blocks[a] = block;
} else if (block !== null) { } else if (block) {
destroy_each_item_block(block, active_transitions, apply_transitions); destroy_each_item_block(block, active_transitions, apply_transitions);
} }
} }
@ -628,7 +628,7 @@ function mark_lis(a) {
function insert_each_item_block(block, dom, is_controlled, sibling) { function insert_each_item_block(block, dom, is_controlled, sibling) {
var current = /** @type {import('./types.js').TemplateNode} */ (block.d); var current = /** @type {import('./types.js').TemplateNode} */ (block.d);
if (sibling === null) { if (!sibling) {
if (is_controlled) { if (is_controlled) {
return insert(current, /** @type {Element} */ (dom), null); return insert(current, /** @type {Element} */ (dom), null);
} else { } else {
@ -668,7 +668,7 @@ function destroy_active_transition_blocks(active_transitions) {
for (; i < length; i++) { for (; i < length; i++) {
block = active_transitions[i]; block = active_transitions[i];
transition = block.r; transition = block.r;
if (transition !== null) { if (!transition) {
block.r = null; block.r = null;
destroy_each_item_block(block, null, false); destroy_each_item_block(block, null, false);
} }
@ -714,7 +714,7 @@ function update_each_item_block(block, item, index, type) {
const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0; const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0;
// Handle each item animations // Handle each item animations
const each_animation = block.a; const each_animation = block.a;
if (transitions !== null && (type & EACH_KEYED) !== 0 && each_animation !== null) { if (transitions && (type & EACH_KEYED) !== 0 && each_animation) {
each_animation(block, transitions, index, index_is_reactive); each_animation(block, transitions, index, index_is_reactive);
} }
if (index_is_reactive) { if (index_is_reactive) {
@ -739,7 +739,7 @@ export function destroy_each_item_block(
) { ) {
const transitions = block.s; const transitions = block.s;
if (apply_transitions && transitions !== null) { if (apply_transitions && transitions) {
// We might have pending key transitions, if so remove them first // We might have pending key transitions, if so remove them first
for (let other of transitions) { for (let other of transitions) {
if (other.r === 'key') { if (other.r === 'key') {
@ -750,14 +750,14 @@ export function destroy_each_item_block(
block.s = null; block.s = null;
} else { } else {
trigger_transitions(transitions, 'out'); trigger_transitions(transitions, 'out');
if (transition_block !== null) { if (transition_block) {
transition_block.push(block); transition_block.push(block);
} }
return; return;
} }
} }
const dom = block.d; const dom = block.d;
if (!controlled && dom !== null) { if (!controlled && dom) {
remove(dom); remove(dom);
} }
destroy_signal(/** @type {import('./types.js').EffectSignal} */ (block.e)); destroy_signal(/** @type {import('./types.js').EffectSignal} */ (block.e));

@ -27,7 +27,7 @@ export function get_hydration_fragment(node) {
/** @type {null | string} */ /** @type {null | string} */
let target_depth = null; let target_depth = null;
while (current_node !== null) { while (current_node) {
const node_type = current_node.nodeType; const node_type = current_node.nodeType;
const next_sibling = current_node.nextSibling; const next_sibling = current_node.nextSibling;
if (node_type === 8) { if (node_type === 8) {
@ -61,7 +61,7 @@ export function get_hydration_fragment(node) {
export function hydrate_block_anchor(anchor_node, is_controlled) { export function hydrate_block_anchor(anchor_node, is_controlled) {
/** @type {Node} */ /** @type {Node} */
let target_node = anchor_node; let target_node = anchor_node;
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
if (is_controlled) { if (is_controlled) {
target_node = /** @type {Node} */ (target_node.firstChild); target_node = /** @type {Node} */ (target_node.firstChild);
} }
@ -79,7 +79,7 @@ export function hydrate_block_anchor(anchor_node, is_controlled) {
set_current_hydration_fragment(fragment); set_current_hydration_fragment(fragment);
} else { } else {
const first_child = /** @type {Element | null} */ (target_node.firstChild); const first_child = /** @type {Element | null} */ (target_node.firstChild);
set_current_hydration_fragment(first_child === null ? [] : [first_child]); set_current_hydration_fragment(!first_child ? [] : [first_child]);
} }
} }
} }

@ -166,9 +166,9 @@ export function clone_node(node, deep) {
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function child(node) { export function child(node) {
const child = first_child_get.call(node); const child = first_child_get.call(node);
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
// Child can be null if we have an element with a single child, like `<p>{text}</p>`, where `text` is empty // Child can be null if we have an element with a single child, like `<p>{text}</p>`, where `text` is empty
if (child === null) { if (!child) {
const text = document.createTextNode(''); const text = document.createTextNode('');
node.appendChild(text); node.appendChild(text);
return text; return text;
@ -186,9 +186,9 @@ export function child(node) {
*/ */
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function child_frag(node) { export function child_frag(node) {
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
const first_node = /** @type {Node[]} */ (node)[0]; const first_node = /** @type {Node[]} */ (node)[0];
if (current_hydration_fragment !== null && first_node !== null) { if (current_hydration_fragment && first_node) {
return capture_fragment_from_node(first_node); return capture_fragment_from_node(first_node);
} }
return first_node; return first_node;
@ -204,7 +204,7 @@ export function child_frag(node) {
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function sibling(node) { export function sibling(node) {
const next_sibling = next_sibling_get.call(node); const next_sibling = next_sibling_get.call(node);
if (current_hydration_fragment !== null && next_sibling !== null) { if (current_hydration_fragment && next_sibling) {
return capture_fragment_from_node(next_sibling); return capture_fragment_from_node(next_sibling);
} }
return next_sibling; return next_sibling;

@ -21,18 +21,18 @@ export function insert(current, parent_element, sibling) {
var node; var node;
for (; i < current.length; i++) { for (; i < current.length; i++) {
node = current[i]; node = current[i];
if (sibling === null) { if (sibling) {
append_child(/** @type {Element} */ (parent_element), /** @type {Node} */ (node));
} else {
sibling.before(/** @type {Node} */ (node)); sibling.before(/** @type {Node} */ (node));
} else {
append_child(/** @type {Element} */ (parent_element), /** @type {Node} */ (node));
} }
} }
return current[0]; return current[0];
} else if (current !== null) { } else if (current) {
if (sibling === null) { if (sibling) {
append_child(/** @type {Element} */ (parent_element), /** @type {Node} */ (current));
} else {
sibling.before(/** @type {Node} */ (current)); sibling.before(/** @type {Node} */ (current));
} else {
append_child(/** @type {Element} */ (parent_element), /** @type {Node} */ (current));
} }
} }
return /** @type {Text | Element | Comment} */ (current); return /** @type {Text | Element | Comment} */ (current);
@ -71,7 +71,7 @@ export function remove(current) {
*/ */
export function reconcile_html(dom, value, svg) { export function reconcile_html(dom, value, svg) {
hydrate_block_anchor(dom); hydrate_block_anchor(dom);
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
return current_hydration_fragment; return current_hydration_fragment;
} }
var html = value + ''; var html = value + '';

@ -124,14 +124,14 @@ export function svg_replace(node) {
* @returns {Element | DocumentFragment | Node[]} * @returns {Element | DocumentFragment | Node[]}
*/ */
function open_template(is_fragment, use_clone_node, anchor, template_element_fn) { function open_template(is_fragment, use_clone_node, anchor, template_element_fn) {
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
if (anchor !== null) { if (anchor) {
hydrate_block_anchor(anchor, false); hydrate_block_anchor(anchor, false);
} }
// In ssr+hydration optimization mode, we might remove the template_element, // In ssr+hydration optimization mode, we might remove the template_element,
// so we need to is_fragment flag to properly handle hydrated content accordingly. // so we need to is_fragment flag to properly handle hydrated content accordingly.
const fragment = current_hydration_fragment; const fragment = current_hydration_fragment;
if (fragment !== null) { if (fragment) {
return is_fragment ? fragment : /** @type {Element} */ (fragment[0]); return is_fragment ? fragment : /** @type {Element} */ (fragment[0]);
} }
} }
@ -196,7 +196,7 @@ function close_template(dom, is_fragment, anchor) {
? dom ? dom
: /** @type {import('./types.js').TemplateNode[]} */ (Array.from(dom.childNodes)) : /** @type {import('./types.js').TemplateNode[]} */ (Array.from(dom.childNodes))
: dom; : dom;
if (anchor !== null) { if (anchor) {
if (current_hydration_fragment === null) { if (current_hydration_fragment === null) {
insert(current, null, anchor); insert(current, null, anchor);
} }
@ -352,7 +352,7 @@ export function class_name(dom, value) {
// @ts-expect-error need to add __className to patched prototype // @ts-expect-error need to add __className to patched prototype
const prev_class_name = dom.__className; const prev_class_name = dom.__className;
const next_class_name = to_class(value); const next_class_name = to_class(value);
const is_hydrating = current_hydration_fragment !== null; const is_hydrating = current_hydration_fragment;
if (is_hydrating && dom.className === next_class_name) { if (is_hydrating && dom.className === next_class_name) {
// In case of hydration don't reset the class as it's already correct. // In case of hydration don't reset the class as it's already correct.
// @ts-expect-error need to add __className to patched prototype // @ts-expect-error need to add __className to patched prototype
@ -389,7 +389,7 @@ export function text(dom, value) {
// @ts-expect-error need to add __value to patched prototype // @ts-expect-error need to add __value to patched prototype
const prev_node_value = dom.__nodeValue; const prev_node_value = dom.__nodeValue;
const next_node_value = stringify(value); const next_node_value = stringify(value);
if (current_hydration_fragment !== null && dom.nodeValue === next_node_value) { if (current_hydration_fragment && dom.nodeValue === next_node_value) {
// In case of hydration don't reset the nodeValue as it's already correct. // In case of hydration don't reset the nodeValue as it's already correct.
// @ts-expect-error need to add __nodeValue to patched prototype // @ts-expect-error need to add __nodeValue to patched prototype
dom.__nodeValue = next_node_value; dom.__nodeValue = next_node_value;
@ -676,7 +676,7 @@ export function bind_playback_rate(media, get_value, update) {
* @param {(paused: boolean) => void} update * @param {(paused: boolean) => void} update
*/ */
export function bind_paused(media, get_value, update) { export function bind_paused(media, get_value, update) {
let mounted = current_hydration_fragment !== null; let mounted = !!current_hydration_fragment;
let paused = get_value(); let paused = get_value();
const callback = () => { const callback = () => {
if (paused !== media.paused) { if (paused !== media.paused) {
@ -979,7 +979,7 @@ export function bind_select_value(dom, get_value, update) {
if (mounting && value === undefined) { if (mounting && value === undefined) {
/** @type {HTMLOptionElement | null} */ /** @type {HTMLOptionElement | null} */
let selected_option = dom.querySelector(':checked'); let selected_option = dom.querySelector(':checked');
if (selected_option !== null) { if (selected_option) {
value = get_option_value(selected_option); value = get_option_value(selected_option);
update(value); update(value);
} }
@ -1050,7 +1050,7 @@ function get_binding_group_value(group, __value, checked) {
export function bind_group(group, group_index, dom, get_value, update) { export function bind_group(group, group_index, dom, get_value, update) {
const is_checkbox = dom.getAttribute('type') === 'checkbox'; const is_checkbox = dom.getAttribute('type') === 'checkbox';
let binding_group = group; let binding_group = group;
if (group_index !== null) { if (group_index) {
for (const index of group_index) { for (const index of group_index) {
const group = binding_group; const group = binding_group;
// @ts-ignore // @ts-ignore
@ -1298,7 +1298,7 @@ function handle_event_propagation(root_element, event) {
} }
}); });
while (current_target !== null) { while (current_target) {
/** @type {null | Element} */ /** @type {null | Element} */
const parent_element = const parent_element =
current_target.parentNode || /** @type {any} */ (current_target).host || null; current_target.parentNode || /** @type {any} */ (current_target).host || null;
@ -1332,7 +1332,7 @@ function handle_event_propagation(root_element, event) {
export function slot(anchor_node, slot_fn, slot_props, fallback_fn) { export function slot(anchor_node, slot_fn, slot_props, fallback_fn) {
hydrate_block_anchor(anchor_node); hydrate_block_anchor(anchor_node);
if (slot_fn === undefined) { if (slot_fn === undefined) {
if (fallback_fn !== null) { if (fallback_fn) {
fallback_fn(anchor_node); fallback_fn(anchor_node);
} }
} else { } else {
@ -1390,7 +1390,7 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
trigger_transitions(alternate_transitions, 'in'); trigger_transitions(alternate_transitions, 'in');
} }
} }
} else if (current_hydration_fragment !== null) { } else if (current_hydration_fragment) {
const comment_text = /** @type {Comment} */ (current_hydration_fragment?.[0])?.data; const comment_text = /** @type {Comment} */ (current_hydration_fragment?.[0])?.data;
if ( if (
!comment_text || !comment_text ||
@ -1415,7 +1415,7 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
// Managed effect // Managed effect
const consequent_effect = render_effect( const consequent_effect = render_effect(
() => { () => {
if (consequent_dom !== null) { if (consequent_dom) {
remove(consequent_dom); remove(consequent_dom);
consequent_dom = null; consequent_dom = null;
} }
@ -1437,12 +1437,12 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
// Managed effect // Managed effect
const alternate_effect = render_effect( const alternate_effect = render_effect(
() => { () => {
if (alternate_dom !== null) { if (alternate_dom) {
remove(alternate_dom); remove(alternate_dom);
alternate_dom = null; alternate_dom = null;
} }
if (!block.v) { if (!block.v) {
if (alternate_fn !== null) { if (alternate_fn) {
alternate_fn(anchor_node); alternate_fn(anchor_node);
} }
if (!has_mounted_branch) { if (!has_mounted_branch) {
@ -1459,10 +1459,10 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
); );
block.ae = alternate_effect; block.ae = alternate_effect;
push_destroy_fn(if_effect, () => { push_destroy_fn(if_effect, () => {
if (consequent_dom !== null) { if (consequent_dom) {
remove(consequent_dom); remove(consequent_dom);
} }
if (alternate_dom !== null) { if (alternate_dom) {
remove(alternate_dom); remove(alternate_dom);
} }
destroy_signal(consequent_effect); destroy_signal(consequent_effect);
@ -1480,15 +1480,16 @@ export function head(render_fn) {
const block = create_head_block(); const block = create_head_block();
// The head function may be called after the first hydration pass and ssr comment nodes may still be present, // The head function may be called after the first hydration pass and ssr comment nodes may still be present,
// therefore we need to skip that when we detect that we're not in hydration mode. // therefore we need to skip that when we detect that we're not in hydration mode.
const hydration_fragment = const hydration_fragment = current_hydration_fragment
current_hydration_fragment !== null ? get_hydration_fragment(document.head.firstChild) : null; ? get_hydration_fragment(document.head.firstChild)
: null;
const previous_hydration_fragment = current_hydration_fragment; const previous_hydration_fragment = current_hydration_fragment;
set_current_hydration_fragment(hydration_fragment); set_current_hydration_fragment(hydration_fragment);
try { try {
const head_effect = render_effect( const head_effect = render_effect(
() => { () => {
const current = block.d; const current = block.d;
if (current !== null) { if (current) {
remove(current); remove(current);
block.d = null; block.d = null;
} }
@ -1504,7 +1505,7 @@ export function head(render_fn) {
); );
push_destroy_fn(head_effect, () => { push_destroy_fn(head_effect, () => {
const current = block.d; const current = block.d;
if (current !== null) { if (current) {
remove(current); remove(current);
} }
}); });
@ -1566,20 +1567,20 @@ export function element(anchor_node, tag_fn, render_fn, is_svg = false) {
const render_effect_signal = render_effect( const render_effect_signal = render_effect(
() => { () => {
const next_element = tag const next_element = tag
? current_hydration_fragment !== null ? current_hydration_fragment
? /** @type {HTMLElement | SVGElement} */ (current_hydration_fragment[0]) ? /** @type {HTMLElement | SVGElement} */ (current_hydration_fragment[0])
: is_svg : is_svg
? document.createElementNS('http://www.w3.org/2000/svg', tag) ? document.createElementNS('http://www.w3.org/2000/svg', tag)
: document.createElement(tag) : document.createElement(tag)
: null; : null;
const prev_element = element; const prev_element = element;
if (prev_element !== null) { if (prev_element) {
block.d = null; block.d = null;
} }
element = next_element; element = next_element;
if (element !== null && render_fn !== undefined) { if (element && render_fn !== undefined) {
let anchor; let anchor;
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
// Use the existing ssr comment as the anchor so that the inner open and close // Use the existing ssr comment as the anchor so that the inner open and close
// methods can pick up the existing nodes correctly // methods can pick up the existing nodes correctly
anchor = /** @type {Comment} */ (element.firstChild); anchor = /** @type {Comment} */ (element.firstChild);
@ -1589,11 +1590,11 @@ export function element(anchor_node, tag_fn, render_fn, is_svg = false) {
} }
render_fn(element, anchor); render_fn(element, anchor);
} }
const has_prev_element = prev_element !== null; const has_prev_element = prev_element;
if (has_prev_element) { if (has_prev_element) {
remove(prev_element); remove(prev_element);
} }
if (element !== null) { if (element) {
insert(element, null, anchor_node); insert(element, null, anchor_node);
if (has_prev_element) { if (has_prev_element) {
const parent_block = block.p; const parent_block = block.p;
@ -1605,7 +1606,7 @@ export function element(anchor_node, tag_fn, render_fn, is_svg = false) {
true true
); );
push_destroy_fn(element_effect, () => { push_destroy_fn(element_effect, () => {
if (element !== null) { if (element) {
remove(element); remove(element);
block.d = null; block.d = null;
element = null; element = null;
@ -1643,8 +1644,8 @@ export function component(anchor_node, component_fn, render_fn) {
transition.f(() => { transition.f(() => {
transitions.delete(transition); transitions.delete(transition);
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.e !== null) { if (render.e) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -1666,7 +1667,7 @@ export function component(anchor_node, component_fn, render_fn) {
const effect = render_effect( const effect = render_effect(
() => { () => {
const current = block.d; const current = block.d;
if (current !== null) { if (current) {
remove(current); remove(current);
block.d = null; block.d = null;
} }
@ -1690,7 +1691,7 @@ export function component(anchor_node, component_fn, render_fn) {
} }
const transitions = render.s; const transitions = render.s;
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -1717,13 +1718,13 @@ export function component(anchor_node, component_fn, render_fn) {
); );
push_destroy_fn(component_effect, () => { push_destroy_fn(component_effect, () => {
let render = current_render; let render = current_render;
while (render !== null) { while (render) {
const dom = render.d; const dom = render.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
} }
const effect = render.e; const effect = render.e;
if (effect !== null) { if (effect) {
destroy_signal(effect); destroy_signal(effect);
} }
render = render.p; render = render.p;
@ -1769,8 +1770,8 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
transition.f(() => { transition.f(() => {
transitions.delete(transition); transitions.delete(transition);
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.e !== null) { if (render.e) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -1794,15 +1795,15 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
if (resolved_value === UNINITIALIZED) { if (resolved_value === UNINITIALIZED) {
// pending = true // pending = true
block.n = true; block.n = true;
if (pending_fn !== null) { if (pending_fn) {
pending_fn(anchor_node); pending_fn(anchor_node);
} }
} else if (then_fn !== null) { } else if (then_fn) {
// pending = false // pending = false
block.n = false; block.n = false;
then_fn(anchor_node, resolved_value); then_fn(anchor_node, resolved_value);
} }
} else if (catch_fn !== null) { } else if (catch_fn) {
// pending = false // pending = false
block.n = false; block.n = false;
catch_fn(anchor_node, error); catch_fn(anchor_node, error);
@ -1825,7 +1826,7 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
} }
const transitions = render.s; const transitions = render.s;
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -1884,13 +1885,13 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
push_destroy_fn(await_effect, () => { push_destroy_fn(await_effect, () => {
let render = current_render; let render = current_render;
latest_token = {}; latest_token = {};
while (render !== null) { while (render) {
const dom = render.d; const dom = render.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
} }
const effect = render.e; const effect = render.e;
if (effect !== null) { if (effect) {
destroy_signal(effect); destroy_signal(effect);
} }
render = render.p; render = render.p;
@ -1929,8 +1930,8 @@ export function key(anchor_node, key, render_fn) {
transition.f(() => { transition.f(() => {
transitions.delete(transition); transitions.delete(transition);
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.e !== null) { if (render.e) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -1969,7 +1970,7 @@ export function key(anchor_node, key, render_fn) {
} }
const transitions = render.s; const transitions = render.s;
if (transitions.size === 0) { if (transitions.size === 0) {
if (render.d !== null) { if (render.d) {
remove(render.d); remove(render.d);
render.d = null; render.d = null;
} }
@ -2000,13 +2001,13 @@ export function key(anchor_node, key, render_fn) {
mounted = true; mounted = true;
push_destroy_fn(key_effect, () => { push_destroy_fn(key_effect, () => {
let render = current_render; let render = current_render;
while (render !== null) { while (render) {
const dom = render.d; const dom = render.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
} }
const effect = render.e; const effect = render.e;
if (effect !== null) { if (effect) {
destroy_signal(effect); destroy_signal(effect);
} }
render = render.p; render = render.p;
@ -2030,7 +2031,7 @@ export function cssProps(anchor, is_html, props, component) {
/** @type {Text | Comment} */ /** @type {Text | Comment} */
let component_anchor; let component_anchor;
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
// Hydration: css props element is surrounded by a ssr comment ... // Hydration: css props element is surrounded by a ssr comment ...
tag = /** @type {HTMLElement | SVGElement} */ (current_hydration_fragment[0]); tag = /** @type {HTMLElement | SVGElement} */ (current_hydration_fragment[0]);
// ... and the child(ren) of the css props element is also surround by a ssr comment // ... and the child(ren) of the css props element is also surround by a ssr comment
@ -2196,7 +2197,7 @@ export function action(dom, action, value_fn) {
* @returns {void} * @returns {void}
*/ */
export function remove_input_attr_defaults(dom) { export function remove_input_attr_defaults(dom) {
if (current_hydration_fragment !== null) { if (current_hydration_fragment) {
attr(dom, 'value', null); attr(dom, 'value', null);
attr(dom, 'checked', null); attr(dom, 'checked', null);
} }
@ -2208,7 +2209,7 @@ export function remove_input_attr_defaults(dom) {
* @returns {void} * @returns {void}
*/ */
export function remove_textarea_child(dom) { export function remove_textarea_child(dom) {
if (current_hydration_fragment !== null && dom.firstChild !== null) { if (current_hydration_fragment && dom.firstChild) {
dom.textContent = ''; dom.textContent = '';
} }
} }
@ -2643,7 +2644,7 @@ const spread_props_handler = {
while (i--) { while (i--) {
let p = target.props[i]; let p = target.props[i];
if (is_function(p)) p = p(); if (is_function(p)) p = p();
if (typeof p === 'object' && p !== null && key in p) return p[key]; if (typeof p === 'object' && p && key in p) return p[key];
} }
}, },
getOwnPropertyDescriptor(target, key) { getOwnPropertyDescriptor(target, key) {
@ -2651,7 +2652,7 @@ const spread_props_handler = {
while (i--) { while (i--) {
let p = target.props[i]; let p = target.props[i];
if (is_function(p)) p = p(); if (is_function(p)) p = p();
if (typeof p === 'object' && p !== null && key in p) return get_descriptor(p, key); if (typeof p === 'object' && p && key in p) return get_descriptor(p, key);
} }
}, },
has(target, key) { has(target, key) {
@ -2795,7 +2796,7 @@ export function mount(component, options) {
); );
block.e = effect; block.e = effect;
} catch (error) { } catch (error) {
if (options.recover !== false && hydration_fragment !== null) { if (options.recover !== false && hydration_fragment) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error( console.error(
'ERR_SVELTE_HYDRATION_MISMATCH' + 'ERR_SVELTE_HYDRATION_MISMATCH' +
@ -2860,10 +2861,10 @@ export function mount(component, options) {
} }
root_event_handles.delete(event_handle); root_event_handles.delete(event_handle);
const dom = block.d; const dom = block.d;
if (dom !== null) { if (dom) {
remove(dom); remove(dom);
} }
if (hydration_fragment !== null) { if (hydration_fragment) {
remove(hydration_fragment); remove(hydration_fragment);
} }
destroy_signal(/** @type {import('./types.js').EffectSignal} */ (block.e)); destroy_signal(/** @type {import('./types.js').EffectSignal} */ (block.e));
@ -2906,7 +2907,7 @@ export function snippet_effect(get_snippet, node, args) {
const snippet = get_snippet(); const snippet = get_snippet();
untrack(() => snippet(node, args)); untrack(() => snippet(node, args));
return () => { return () => {
if (block.d !== null) { if (block.d) {
remove(block.d); remove(block.d);
} }
}; };

Loading…
Cancel
Save