Skip to content

Commit b09ba1a

Browse files
committed
fix(pat-inject): Fix problem with inserting table rows.
There was a problem with injecting table rows introduced in: b0f94fb The problem occured when setting a table row as content of a temporary <div> wrapper. But a <tr> is not a valid child node of a <div>. This caused visually destroyed tables. Using a <template> tag as wrapper instead of a div solved the problem.
1 parent e2f5185 commit b09ba1a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pat/inject/inject.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ const inject = {
459459
/* Called after the XHR has succeeded and we have a new $sources
460460
* element to inject.
461461
*/
462-
const wrapper = document.createElement("div");
462+
const wrapper = document.createElement("template");
463463
if ($sources.length > 0) {
464464
const method = cfg.sourceMod === "content" ? "innerHTML" : "outerHTML";
465465
// There might be multiple sources, so we need to loop over them.
466466
// Access them with "innerHTML" or "outerHTML" depending on the sourceMod.
467467
const sources_string = [...$sources].map(source => source[method]).join("\n");
468468
wrapper.innerHTML = sources_string;
469469

470-
for (const img of wrapper.querySelectorAll("img")) {
470+
for (const img of wrapper.content.querySelectorAll("img")) {
471471
events.add_event_listener(
472472
img,
473473
"load",
@@ -481,7 +481,7 @@ const inject = {
481481
}
482482

483483
// Copy, because after insertion wrapper.children is empty.
484-
const source_nodes = [...wrapper.childNodes];
484+
const source_nodes = [...wrapper.content.childNodes];
485485

486486
// Now the injection actually happens.
487487
if (this._inject(trigger, source_nodes, target, cfg)) {

0 commit comments

Comments
 (0)