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

153
Vistas
Editing the styles of all parent elements using javascript/typescript

I'm attempting to edit the styles of all the parent elements of an element within my shadowroot using a function call, but I keep getting Property 'style' does not exist on type 'Element'. Here is my code:

    var child = this.shadowRoot!.host;
    var parents = [];
    while(child) {
      child = child.parentElement as HTMLElement;
      parents.unshift(child);
    }
    parents.forEach(element => {
      element.style.height='100vh';
      element.style.width='100vw';  
    })

I attempted to define the parents array as HTMLElements specifically, but keep getting the error Conversion of type 'never[]' to type 'HTMLElement' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

How can I either define the parents array as an empty array of HTMLElements specifically, or access the 'style' property of my elements otherwise?

about 4 years ago · Juan Pablo Isaza
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