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

194
Views
Reverse QuerySelector, to get from the element to its inheriting styles

Currently, I'm building an Application that generates from a JSON File, CSS selectors, and styles. I'm currently Attempting to get all styles affecting an element, I have a solution currently which is not good. Currently, every one of my selectors sets the same custom variable with inheriting false, to its id, then I loop through the element and remove depending on what the id is that variable from the id until it's empty again, then I add them back to each CSS selector and use the array I've got.

This solution is bad since it's forcing a lot of reflows when I remove the variable and it scales linearly, but also it's getting slower and slower as more children the element has.

I could get All affecting elements at launch by just looping each selector with query selector, but when I add an element after it started up it would be way too expensive to run query selector for each CSS selector for each element I add and compare them.

Another solution might be writing a reverse algorithm but with that one, it would be extremely complicated due to the sheer complexity of all selectors like nth-child, first, element, by attribute, etc.-

Any thoughts?

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!