Is there a non-polling method to listen for changes to an element's computed style?
This fantasy code snippet should explain what I mean succinctly:
var el = document.getElementById('doodad');
el.addComputedStyleChangeListener('width', function (prev, new) {
alert('Previous width: ' + prev + '; New width: ' + new);
});
I'm aware of the DOMAttrModified
mutation event and the upcoming MutationObserver
, but neither is sufficient -- they can only be used to watch the style
DOM attribute of an element, which doesn't wholly determine an element's computed style.
The use case for this was originally part of this question, which really just lead me down a course of curiosity.
There is no such method. CSS OM is not there yet.
And it is not clear what "computed style change" means.
In principle you can detect change of used (for e.g. rendering) style. But this will need some event like "paint" or "layout" to happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With