From 58ef7600fb12794e28c1b8dcf82de9ea8905e324 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Mon, 30 Dec 2019 17:24:02 -0600 Subject: [PATCH] Avoid copying the table and use querySelector() (Since there's only one .articleBody.) --- Shared/Article Rendering/main.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index e66f7d068..1f856440c 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -23,14 +23,13 @@ function convertImgSrc() { // Wrap tables in an overflow-x: auto; div function wrapTables() { - var tables = document.querySelectorAll("div.articleBody")[0].getElementsByTagName("table"); + var tables = document.querySelector("div.articleBody").getElementsByTagName("table"); for (table of tables) { var wrapper = document.createElement("div"); wrapper.className = "nnw-overflow"; - var tableCopy = table.cloneNode(true); - wrapper.appendChild(tableCopy); - table.parentNode.replaceChild(wrapper, table); + table.parentNode.insertBefore(wrapper, table); + wrapper.appendChild(table); } }