Challenge: Predict what an element’s calculated CSS property would fall back to if it’s effective value was deleted – without causing style flickers?

Let’s say we have an HTMLElement that is styled inline relative to a given CSS property and that window.getComputedStyle(HTMLElement).getPropertyValue(theCSSProperty) returns the value reflecting the inline styling.

If we did: HTMLElement.style.removeProperty(theCSSProperty), window.getComputedStyle(HTMLElement ).getPropertyValue(theCSSProperty) would show the fallback value (not necessarily the same as the default value).

I would like to be able to predict that fallback value without actually deleting the effective value, but with my current take at it, it seems quite difficult because the process of calculating the effective style, as this post hints at, is not at all that simple.

I have thought about other hackish solutions such as cloning the element out of sight and manipulating the clone instead, but that is not a bullet proof solution – due to possible nth-child styling for one thing.

So my conclusion is: It ain’t easy (not the same as undoable). But before I leave it at that, I thought I might as well check with the community that there isn’t some obvious solution I have missed. How would you approach this if you had to?