I am trying to detect style changes in the HTML tag and get the resulting changes. But most the tutorials usually just show how to detect the change but not how to extract the information about the changes.
var variables_observer=new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
var STYLE = STYLE THAT CHANGED
var VALUE = STYLE VALUE THAT CHANGED
console.log(STYLE);
console.log(VALUE);
});
});
var target=document.documentElement;
variables_observer.observe(target,{attributes:true,attributeFilter:['style']});
For example, if I add a variable to my style --size1:100px is added to my style:
Before:
<html>
After:
<html style="--size1:100px">
Console:
--size1
100px
Does mutation give any change data? And what exactly changed and how it changed?
I tried to set the ID for the html tag and immediately set the background color for it. In
setTimeoutI change the background color and display in the MutationObserver object the type of change, the tag on which they occurred, the new and old color values.