|
|
@ -79,8 +79,7 @@ export function set_text(text, value) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function mount(component, options) {
|
|
|
|
export function mount(component, options) {
|
|
|
|
const anchor = options.anchor ?? options.target.appendChild(empty());
|
|
|
|
const anchor = options.anchor ?? options.target.appendChild(empty());
|
|
|
|
// Don't flush previous effects to ensure order of outer effects stays consistent
|
|
|
|
return _mount(component, { ...options, anchor });
|
|
|
|
return flush_sync(() => _mount(component, { ...options, anchor }), false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -113,40 +112,35 @@ export function hydrate(component, options) {
|
|
|
|
const previous_hydrate_node = hydrate_node;
|
|
|
|
const previous_hydrate_node = hydrate_node;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Don't flush previous effects to ensure order of outer effects stays consistent
|
|
|
|
var anchor = /** @type {import('#client').TemplateNode} */ (target.firstChild);
|
|
|
|
return flush_sync(() => {
|
|
|
|
while (
|
|
|
|
var anchor = /** @type {import('#client').TemplateNode} */ (target.firstChild);
|
|
|
|
anchor &&
|
|
|
|
while (
|
|
|
|
(anchor.nodeType !== 8 || /** @type {Comment} */ (anchor).data !== HYDRATION_START)
|
|
|
|
anchor &&
|
|
|
|
) {
|
|
|
|
(anchor.nodeType !== 8 || /** @type {Comment} */ (anchor).data !== HYDRATION_START)
|
|
|
|
anchor = /** @type {import('#client').TemplateNode} */ (anchor.nextSibling);
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
anchor = /** @type {import('#client').TemplateNode} */ (anchor.nextSibling);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!anchor) {
|
|
|
|
if (!anchor) {
|
|
|
|
throw HYDRATION_ERROR;
|
|
|
|
throw HYDRATION_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set_hydrating(true);
|
|
|
|
set_hydrating(true);
|
|
|
|
set_hydrate_node(/** @type {Comment} */ (anchor));
|
|
|
|
set_hydrate_node(/** @type {Comment} */ (anchor));
|
|
|
|
hydrate_next();
|
|
|
|
hydrate_next();
|
|
|
|
|
|
|
|
|
|
|
|
const instance = _mount(component, { ...options, anchor });
|
|
|
|
const instance = _mount(component, { ...options, anchor });
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
hydrate_node.nodeType !== 8 ||
|
|
|
|
hydrate_node.nodeType !== 8 ||
|
|
|
|
/** @type {Comment} */ (hydrate_node).data !== HYDRATION_END
|
|
|
|
/** @type {Comment} */ (hydrate_node).data !== HYDRATION_END
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
w.hydration_mismatch();
|
|
|
|
w.hydration_mismatch();
|
|
|
|
throw HYDRATION_ERROR;
|
|
|
|
throw HYDRATION_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// flush_sync will run this callback and then synchronously run any pending effects,
|
|
|
|
set_hydrating(false);
|
|
|
|
// which don't belong to the hydration phase anymore - therefore reset it here
|
|
|
|
|
|
|
|
set_hydrating(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
return /** @type {Exports} */ (instance);
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
if (error === HYDRATION_ERROR) {
|
|
|
|
if (error === HYDRATION_ERROR) {
|
|
|
|
// TODO it's possible for event listeners to have been added and
|
|
|
|
// TODO it's possible for event listeners to have been added and
|
|
|
|