|
|
|
@ -4,7 +4,7 @@ import { EFFECT_TRANSPARENT } from '#client/constants';
|
|
|
|
|
import { block, branch, pause_effect } from '../../reactivity/effects.js';
|
|
|
|
|
import { current_batch } from '../../reactivity/batch.js';
|
|
|
|
|
import { hydrate_next, hydrate_node, hydrating } from '../hydration.js';
|
|
|
|
|
import { create_text, should_defer_append } from '../operations.js';
|
|
|
|
|
import { should_defer_append } from '../operations.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @template P
|
|
|
|
@ -27,19 +27,13 @@ export function component(node, get_component, render_fn) {
|
|
|
|
|
/** @type {Effect | null} */
|
|
|
|
|
var effect;
|
|
|
|
|
|
|
|
|
|
/** @type {DocumentFragment | null} */
|
|
|
|
|
var offscreen_fragment = null;
|
|
|
|
|
|
|
|
|
|
/** @type {Effect | null} */
|
|
|
|
|
var pending_effect = null;
|
|
|
|
|
|
|
|
|
|
function commit() {
|
|
|
|
|
if (offscreen_fragment) {
|
|
|
|
|
// remove the anchor
|
|
|
|
|
/** @type {Text} */ (offscreen_fragment.lastChild).remove();
|
|
|
|
|
|
|
|
|
|
anchor.before(offscreen_fragment);
|
|
|
|
|
offscreen_fragment = null;
|
|
|
|
|
if (effect) {
|
|
|
|
|
pause_effect(effect);
|
|
|
|
|
effect = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
effect = pending_effect;
|
|
|
|
@ -51,25 +45,23 @@ export function component(node, get_component, render_fn) {
|
|
|
|
|
|
|
|
|
|
var defer = should_defer_append();
|
|
|
|
|
|
|
|
|
|
if (effect) {
|
|
|
|
|
pause_effect(effect);
|
|
|
|
|
effect = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (component) {
|
|
|
|
|
var target = anchor;
|
|
|
|
|
|
|
|
|
|
if (defer) {
|
|
|
|
|
offscreen_fragment = document.createDocumentFragment();
|
|
|
|
|
offscreen_fragment.append((target = create_text()));
|
|
|
|
|
if (effect) {
|
|
|
|
|
/** @type {Batch} */ (current_batch).skipped_effects.add(effect);
|
|
|
|
|
}
|
|
|
|
|
/** @type {Batch} */ (current_batch).add_callback(() => {
|
|
|
|
|
if (effect) {
|
|
|
|
|
pause_effect(effect);
|
|
|
|
|
effect = null;
|
|
|
|
|
}
|
|
|
|
|
pending_effect = branch(() => render_fn(target, component));
|
|
|
|
|
effect = branch(() => render_fn(anchor, component));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
pending_effect = branch(() => render_fn(anchor, component));
|
|
|
|
|
commit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defer) {
|
|
|
|
|
} else if (defer) {
|
|
|
|
|
/** @type {Batch} */ (current_batch).add_callback(commit);
|
|
|
|
|
} else {
|
|
|
|
|
commit();
|
|
|
|
|