Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Web Components / Shadow Dom #3

Open
rameshvarun opened this issue Jul 8, 2023 · 2 comments
Open

Investigate Web Components / Shadow Dom #3

rameshvarun opened this issue Jul 8, 2023 · 2 comments

Comments

@rameshvarun
Copy link
Owner

No description provided.

@Danny-Engelman
Copy link

Danny-Engelman commented Oct 5, 2023

It wil run in a Web Component without shadowDOM, because its just HTML

It does not run in shadowDOM because the code runs querySelectorAll

@Danny-Engelman
Copy link

Danny-Engelman commented Oct 7, 2023

Note!

You can't have the Web Component check if the CSS and JS exist, and if not inject them in the page.
Looks like the init/display ends up in an endless loop

Because you only trigger on DOMContentLoaded, maybe monitor for (new) scripts with the MutationObserver API

const domLoaded = new Promise<void>((resolve) => {
  document.addEventListener("DOMContentLoaded", () => resolve());
});

domLoaded.then(() => {
  // Transform all script / pre tags into cells.
  const scripts = document.querySelectorAll(
    "script[type='text/notebook-cell'], pre.notebook-cell"
  ) as NodeListOf<HTMLScriptElement>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants