Skip to content

Instantly share code, notes, and snippets.

@jcheng5
Created April 3, 2020 20:27
Show Gist options
  • Save jcheng5/4d69fbcb9625c9b3897260f60a226dca to your computer and use it in GitHub Desktop.
Save jcheng5/4d69fbcb9625c9b3897260f60a226dca to your computer and use it in GitHub Desktop.
```{js echo=FALSE}
function enshadowGtTable(tableEl) {
var containerEl = tableEl.parentElement;
var styleEl = containerEl.previousElementSibling;
if (containerEl.tagName !== "DIV" || styleEl.tagName !== "STYLE") {
throw new Error("Unexpected document structure");
}
var shadowDiv = document.createElement("div");
shadowDiv.classList.add("gt-shadow-container");
containerEl.parentElement.insertBefore(shadowDiv, styleEl);
var shadowRoot = shadowDiv.attachShadow({mode: "open"});
shadowRoot.appendChild(styleEl);
shadowRoot.appendChild(containerEl);
}
document.querySelectorAll(".gt_table").forEach(enshadowGtTable);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment