mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Modernize and fix website build tooling deps and utilize JS type checking (#3348)
* Modernize and fix website build tooling deps and utilize JS type checking * Upgrade to the latest Node.js
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll("section p").forEach((paragraph) => {
|
||||
const /** @type {[Text, NodeList][]} */ mutationQueue = [];
|
||||
|
||||
// Recursively traverse the DOM tree and modify the text nodes
|
||||
const recursivelyAddWbr = (node) => {
|
||||
const recursivelyAddWbr = (/** @type {ChildNode} **/ node) => {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
if (!(node instanceof Text)) return;
|
||||
|
||||
const newNodes = node.textContent.split("/");
|
||||
for (let i = 0; i < newNodes.length - 1; i++) {
|
||||
newNodes[i] += "/";
|
||||
@@ -17,12 +21,11 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
node.childNodes.forEach(recursivelyAddWbr);
|
||||
}
|
||||
};
|
||||
|
||||
// Perform the recursive traversal and replace the text nodes
|
||||
const mutationQueue = [];
|
||||
|
||||
// Perform the recursive traversal
|
||||
recursivelyAddWbr(paragraph);
|
||||
mutationQueue.forEach(([node, newNodes]) => {
|
||||
node.replaceWith(...newNodes);
|
||||
});
|
||||
|
||||
// Replace the text nodes
|
||||
mutationQueue.forEach(([node, newNodes]) => node.replaceWith(...newNodes));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user