MCPcopy
hub / github.com/lit/lit / appendChild

Method appendChild

packages/localize-tools/src/formatters/xliff.ts:425–440  ·  view source on GitHub ↗

* Append childNode to parentNode, try to preserve some * whitespace / indentation for common scenarios.

(
    parentNode: Node,
    childNode: Node,
    level: number,
    indent: Function
  )

Source from the content-addressed store, hash-verified

423 * whitespace / indentation for common scenarios.
424 */
425 private appendChild(
426 parentNode: Node,
427 childNode: Node,
428 level: number,
429 indent: Function
430 ) {
431 const lastChild = parentNode.lastChild;
432 if (lastChild) {
433 parentNode.insertBefore(indent(parentNode, level), lastChild);
434 parentNode.insertBefore(childNode, lastChild);
435 } else {
436 parentNode.appendChild(indent(parentNode, level));
437 parentNode.appendChild(childNode);
438 parentNode.appendChild(indent(parentNode, level - 1));
439 }
440 }
441
442 private removeChildAndPrecedingText(parentNode: Node, childNode: Node) {
443 if (childNode.previousSibling?.nodeType === childNode.TEXT_NODE) {

Callers 15

encodeLocaleMethod · 0.95
watch_test.tsFile · 0.80
html-tag_test.tsFile · 0.80
renderElementFunction · 0.80
task_test.tsFile · 0.80

Calls 1

indentFunction · 0.85

Tested by

no test coverage detected