From 7c7b52bb2d241f9d42eabcedaad5fd8b17f76e77 Mon Sep 17 00:00:00 2001
From: Eugen Neuber <eugen.neuber@tugraz.at>
Date: Wed, 13 Jan 2021 09:47:54 +0100
Subject: [PATCH] Add *unboserved* attributes to the internal list of
 properties

When added in HTML a mutation observer does not recognize them...
---
 packages/provider/src/provider.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/packages/provider/src/provider.js b/packages/provider/src/provider.js
index ac514bc0..297236c0 100644
--- a/packages/provider/src/provider.js
+++ b/packages/provider/src/provider.js
@@ -107,7 +107,7 @@ export class Provider extends HTMLElement {
             for(const mutation of mutationsList) {
                 if (mutation.type === 'attributes') {
                     const name = mutation.attributeName;
-                    console.log('The ' + name + ' attribute was modified.');
+                    console.log('Provider (' + that.id() + ') observed attribute "' + name + '" changed');
                     that[name] = that.getAttribute(name);
                     that.callbackStore.forEach(item => {
                         if (item.name === name) {
@@ -123,6 +123,22 @@ export class Provider extends HTMLElement {
 
         // Start observing the target node for configured mutations
         observer.observe(this, config);
+
+        // get all *not observed* attributes
+        if (this.hasAttributes()) {
+            const attrs = this.attributes;
+            for(let i = attrs.length - 1; i >= 0; i--) {
+                if (['id', 'class', 'style', 'data-tag-name'].includes(attrs[i].name)) {
+                    continue;
+                }
+                if (Provider.observedAttributes.includes(attrs[i].name)) {
+                    continue;
+                }
+
+                this[attrs[i].name] = attrs[i].value;
+                console.log('Provider (' + that.id() + ') found attribute "' + attrs[i].name + '" = "' + attrs[i].value + '"');
+            }
+        }
     }
 
     id() {
-- 
GitLab