Skip to content
Snippets Groups Projects
Commit b8769260 authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon:
Browse files

Add some code for an observer

(only a prove of concept)
parent 1972b2ce
No related branches found
No related tags found
1 merge request!28Observer test
...@@ -97,6 +97,25 @@ export class Provider extends HTMLElement { ...@@ -97,6 +97,25 @@ export class Provider extends HTMLElement {
e.stopPropagation(); e.stopPropagation();
} }
}, false); }, false);
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: false, subtree: false };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for(const mutation of mutationsList) {
if (mutation.type === 'attributes') {
console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(this, config);
} }
id() { id() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment