Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!