Skip to content

Commit

Permalink
Fix parentNode not being set when setting text content
Browse files Browse the repository at this point in the history
  • Loading branch information
cohenerickson committed Jan 15, 2024
1 parent 292bde7 commit cfa3a7b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {Node, ParentNode} from './nodeTypes.js';
import type {Node} from './nodeTypes.js';
import {isCommentNode, isTextNode, isParentNode} from './typeGuards.js';
import {createTextNode} from './creation.js';
import {queryAll} from './traversal.js';
import {appendChild} from './treeMutation.js';

/**
* Computes the text content of a given node using a similar
Expand Down Expand Up @@ -41,8 +42,7 @@ export function setTextContent(node: Node, text: string): void {
} else if (isTextNode(node)) {
node.value = text;
} else if (isParentNode(node)) {
var parent: ParentNode = node;

parent.childNodes = [createTextNode(text)];
node.childNodes = [];
appendChild(node, createTextNode(text));
}
}

0 comments on commit cfa3a7b

Please sign in to comment.