|
|
|
@ -46,47 +46,39 @@ export function update_hydrate_nodes(first, insert_text) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function get_hydrate_nodes(node, insert_text = false) {
|
|
|
|
function get_hydrate_nodes(node, insert_text = false) {
|
|
|
|
/** @type {import('#client').TemplateNode[]} */
|
|
|
|
/** @type {import('#client').TemplateNode[]} */
|
|
|
|
const nodes = [];
|
|
|
|
var nodes = [];
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {null | Node} */
|
|
|
|
/** @type {null | Node} */
|
|
|
|
let current_node = node;
|
|
|
|
var current_node = node;
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {null | string} */
|
|
|
|
/** @type {null | string} */
|
|
|
|
let target_depth = null;
|
|
|
|
var target_depth = null;
|
|
|
|
|
|
|
|
|
|
|
|
while (current_node !== null) {
|
|
|
|
while (current_node !== null) {
|
|
|
|
const node_type = current_node.nodeType;
|
|
|
|
if (current_node.nodeType === 8) {
|
|
|
|
const next_sibling = current_node.nextSibling;
|
|
|
|
var data = /** @type {Comment} */ (current_node).data;
|
|
|
|
|
|
|
|
|
|
|
|
if (node_type === 8) {
|
|
|
|
|
|
|
|
const data = /** @type {Comment} */ (current_node).data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.startsWith('ssr:')) {
|
|
|
|
if (data.startsWith('ssr:')) {
|
|
|
|
const depth = data.slice(4);
|
|
|
|
var depth = data.slice(4);
|
|
|
|
|
|
|
|
|
|
|
|
if (target_depth === null) {
|
|
|
|
if (target_depth === null) {
|
|
|
|
target_depth = depth;
|
|
|
|
target_depth = depth;
|
|
|
|
} else if (depth === target_depth) {
|
|
|
|
} else if (depth === target_depth) {
|
|
|
|
if (insert_text && nodes.length === 0) {
|
|
|
|
if (insert_text && nodes.length === 0) {
|
|
|
|
const text = empty();
|
|
|
|
var text = empty();
|
|
|
|
nodes.push(text);
|
|
|
|
nodes.push(text);
|
|
|
|
/** @type {Node} */ (current_node.parentNode).insertBefore(text, current_node);
|
|
|
|
text.before(current_node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nodes;
|
|
|
|
return nodes;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
nodes.push(/** @type {Text | Comment | Element} */ (current_node));
|
|
|
|
nodes.push(/** @type {Text | Comment | Element} */ (current_node));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
current_node = next_sibling;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (target_depth !== null) {
|
|
|
|
|
|
|
|
|
|
|
|
if (target_depth !== null) {
|
|
|
|
|
|
|
|
nodes.push(/** @type {Text | Comment | Element} */ (current_node));
|
|
|
|
nodes.push(/** @type {Text | Comment | Element} */ (current_node));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
current_node = next_sibling;
|
|
|
|
current_node = current_node.nextSibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
|