Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

286
Vistas
I want to wait until the Shadow DOM elements are loaded

I am developing a Chrome extension.

I would like to develop a feature that when you Hover an element on the page, a frame appears around the element, but it doesn't work with the Shadow DOM element.

I believe this is due to the fact that the shadow dom element is not loaded on the page at the time the load event fires.

This is especially true for pages with nested shadow doms. ex.) https://developer.servicenow.com/dev.do

However, I do not know how to detect that the entire page, including the shadow dom, has finished loading.

Please let me know if you know of a solution.

function addAttribute(e) {
  const el = e.path || (e.composedPath && e.composedPath());
  el.setAttribute('style', "outline: solid 4px !important");
}

function removeAttribute(e) {
  const el = e.path || (e.composedPath && e.composedPath());
  el.removeAttribute('style', "outline: solid 4px !important");
}

function addEventListenerToShadow(root) {
  const tw = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
  
  do {
    const currentNode = tw.currentNode;
    if (currentNode instanceof ShadowRoot) continue;
    if (currentNode.shadowRoot) {
      currentNode.shadowRoot.addEventListener('mouseover', addAttribute)
      currentNode.shadowRoot.addEventListener('mouseout', removeAttribute)
      addEventListenerToShadow(currentNode.shadowRoot);
    }
  } while (tw.nextNode());
}

window.onload = addEventListenerToShadow(document.body);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

(nested) shadowDOM are (DOM) children entering your class-room.

Only when you know how many there will come you know when the last one entered.

That means each (shadow) DOM/Element should notify it will come to the main application.

And the application then processes/counts down each "arrived" DOM Child/shadowDOM

The connectedCallback fires on the opening TAG of your Custom Element

So that is the appropriate time to send a CustomEvent I_WILL_COME to the application.

BUT... in your use-case you do not have control over what components do. So the only escape is just wait N seconds and consider your page loaded.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda