|
|
@ -1,6 +1,7 @@
|
|
|
|
import { hydrate_anchor, hydrate_nodes, hydrating } from './hydration.js';
|
|
|
|
import { hydrate_anchor, hydrating } from './hydration.js';
|
|
|
|
import { DEV } from 'esm-env';
|
|
|
|
import { DEV } from 'esm-env';
|
|
|
|
import { init_array_prototype_warnings } from '../dev/equality.js';
|
|
|
|
import { init_array_prototype_warnings } from '../dev/equality.js';
|
|
|
|
|
|
|
|
import { current_effect } from '../runtime.js';
|
|
|
|
|
|
|
|
|
|
|
|
// We cache the Node and Element prototype methods, so that we can avoid doing
|
|
|
|
// We cache the Node and Element prototype methods, so that we can avoid doing
|
|
|
|
// expensive prototype chain lookups.
|
|
|
|
// expensive prototype chain lookups.
|
|
|
@ -96,14 +97,19 @@ export function first_child(fragment, is_text) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// when we _are_ hydrating, `fragment` is an array of nodes
|
|
|
|
// when we _are_ hydrating, `fragment` is an array of nodes
|
|
|
|
const first_node = /** @type {import('#client').TemplateNode[]} */ (fragment)[0];
|
|
|
|
var first_node = /** @type {import('#client').TemplateNode[]} */ (fragment)[0];
|
|
|
|
|
|
|
|
|
|
|
|
// if an {expression} is empty during SSR, there might be no
|
|
|
|
// if an {expression} is empty during SSR, there might be no
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
if (is_text && first_node?.nodeType !== 3) {
|
|
|
|
if (is_text && first_node?.nodeType !== 3) {
|
|
|
|
const text = empty();
|
|
|
|
var text = empty();
|
|
|
|
hydrate_nodes.unshift(text);
|
|
|
|
var dom = /** @type {import('#client').TemplateNode[]} */ (
|
|
|
|
|
|
|
|
/** @type {import('#client').Effect} */ (current_effect).dom
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dom.unshift(text);
|
|
|
|
first_node?.before(text);
|
|
|
|
first_node?.before(text);
|
|
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -127,14 +133,13 @@ export function sibling(node, is_text = false) {
|
|
|
|
// if a sibling {expression} is empty during SSR, there might be no
|
|
|
|
// if a sibling {expression} is empty during SSR, there might be no
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
if (is_text && next_sibling?.nodeType !== 3) {
|
|
|
|
if (is_text && next_sibling?.nodeType !== 3) {
|
|
|
|
const text = empty();
|
|
|
|
var text = empty();
|
|
|
|
if (next_sibling) {
|
|
|
|
var dom = /** @type {import('#client').TemplateNode[]} */ (
|
|
|
|
const index = hydrate_nodes.indexOf(/** @type {Text | Comment | Element} */ (next_sibling));
|
|
|
|
/** @type {import('#client').Effect} */ (current_effect).dom
|
|
|
|
hydrate_nodes.splice(index, 0, text);
|
|
|
|
);
|
|
|
|
next_sibling.before(text);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dom.unshift(text);
|
|
|
|
hydrate_nodes.push(text);
|
|
|
|
next_sibling?.before(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|