Any suggested implementations of a CSS property change listener? Maybe:
thread =
function getValues(){
while(true){
for each CSS property{
if(properties[property] != nil && getValue(property) != properties[property]){alert('change')}
else{properties[property] = getValue(property)}
}
}
}
Mutation events like DOMAttrModified
are deprecated. Consider using a MutationObserver instead.
Example:
<div>use devtools to change the <code>background-color</code> property of this node to <code>red</code></div>
<p>status...</p>
JS:
var observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.target.style.color === 'red') {
document.querySelector('p').textContent = 'success';
}
});
});
var observerConfig = {
attributes: true,
childList: false,
characterData: false,
attributeOldValue: true
};
var targetNode = document.querySelector('div');
observer.observe(targetNode, observerConfig);
I think you're looking for this:
document.documentElement.addEventListener('DOMAttrModified', function(e){
if (e.attrName === 'style') {
console.log('prevValue: ' + e.prevValue, 'newValue: ' + e.newValue);
}
}, false);
If you google for it, a bunch of stuff comes up. This looks promising though:
http://darcyclarke.me/development/detect-attribute-changes-with-jquery/
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