|
|
|
@ -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 { 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
|
|
|
|
|
// 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
|
|
|
|
|
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
|
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
|
if (is_text && first_node?.nodeType !== 3) {
|
|
|
|
|
const text = empty();
|
|
|
|
|
hydrate_nodes.unshift(text);
|
|
|
|
|
var text = empty();
|
|
|
|
|
var dom = /** @type {import('#client').TemplateNode[]} */ (
|
|
|
|
|
/** @type {import('#client').Effect} */ (current_effect).dom
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
dom.unshift(text);
|
|
|
|
|
first_node?.before(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
|
|
|
|
|
// text node to hydrate — we must therefore create one
|
|
|
|
|
if (is_text && next_sibling?.nodeType !== 3) {
|
|
|
|
|
const text = empty();
|
|
|
|
|
if (next_sibling) {
|
|
|
|
|
const index = hydrate_nodes.indexOf(/** @type {Text | Comment | Element} */ (next_sibling));
|
|
|
|
|
hydrate_nodes.splice(index, 0, text);
|
|
|
|
|
next_sibling.before(text);
|
|
|
|
|
} else {
|
|
|
|
|
hydrate_nodes.push(text);
|
|
|
|
|
}
|
|
|
|
|
var text = empty();
|
|
|
|
|
var dom = /** @type {import('#client').TemplateNode[]} */ (
|
|
|
|
|
/** @type {import('#client').Effect} */ (current_effect).dom
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
dom.unshift(text);
|
|
|
|
|
next_sibling?.before(text);
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|