MCPcopy
hub / github.com/sveltejs/svelte / text

Function text

packages/svelte/src/internal/client/dom/template.js:311–330  ·  view source on GitHub ↗
(value = '')

Source from the content-addressed store, hash-verified

309 * @param {any} value
310 */
311export function text(value = '') {
312 if (!hydrating) {
313 var t = create_text(value + '');
314 assign_nodes(t, t);
315 return t;
316 }
317
318 var node = hydrate_node;
319
320 if (node.nodeType !== TEXT_NODE) {
321 // if an {expression} is empty during SSR, we need to insert an empty text node
322 node.before((node = create_text()));
323 set_hydrate_node(node);
324 } else {
325 merge_text_nodes(/** @type {Text} */ (node));
326 }
327
328 assign_nodes(node, node);
329 return node;
330}
331
332/**
333 * @returns {TemplateNode | DocumentFragment}

Callers

nothing calls this directly

Calls 4

create_textFunction · 0.90
set_hydrate_nodeFunction · 0.90
merge_text_nodesFunction · 0.90
assign_nodesFunction · 0.85

Tested by

no test coverage detected