0

Is there a way to map the computed style of a dom element (as retrieved by window.getComputedStyle) to a corresponding CSSStyleRule in document.styleSheets?

My ultimate goal is to retrieve specified values for dom elements (rather than computed values or actual values).

1 Answer 1

2

As far as I know, only IE (with element.currentStyle) allows JS to retrieve the specified values, which is a good thing in my opinion. All the other browsers return the computed values.

I once needed the specified value and the only thing that crossed my mind was to make a CSS parser that would map an element to a rule based on the element's xpath. It would have been some kind of a reversed jQuery, where you would supply a DOM element and it would have returned the CSS rules associated with it after parsing all the loaded CSS. Unfortunately I didn't have the time to start the project.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.