Skip to content
Snippets Groups Projects
Unverified Commit 27ed189f authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Reflect attributes if they exist (dbp/apps/library#77)

parent c5b4c413
No related branches found
No related tags found
No related merge requests found
Pipeline #15786 passed
...@@ -6,6 +6,8 @@ export class AdapterLitElement extends LitElement { ...@@ -6,6 +6,8 @@ export class AdapterLitElement extends LitElement {
this.connected = false; this.connected = false;
this.deferSubscribe = false; this.deferSubscribe = false;
this.deferUnSubscribe = false; this.deferUnSubscribe = false;
// attributes (if they exist) will be updated if a property is changed by "subscribe"
this.reflectAttribute = true;
// default values // default values
this.subscribe = ''; this.subscribe = '';
...@@ -49,12 +51,15 @@ export class AdapterLitElement extends LitElement { ...@@ -49,12 +51,15 @@ export class AdapterLitElement extends LitElement {
console.log('AdapterLitElement(' + that.tagName + ') sub/Callback ' + global + ' -> ' + local + ' = ' + value); console.log('AdapterLitElement(' + that.tagName + ') sub/Callback ' + global + ' -> ' + local + ' = ' + value);
that.attributeChangedCallback(local, that[local], value); that.attributeChangedCallback(local, that[local], value);
// we don't support attributes and provider values at the same time // check if an attribute also exists in the tag
if (that.getAttribute(local) !== null) { if (that.getAttribute(local) !== null) {
// we don't support attributes and provider values at the same time
console.warn('Provider callback: "' + local + '" is also an attribute in tag "' + that.tagName + '", this is not supported!'); console.warn('Provider callback: "' + local + '" is also an attribute in tag "' + that.tagName + '", this is not supported!');
} else {
// we don't want to set the attribute // update attribute if reflectAttribute is enabled
// that.setAttribute(local, value); if (that.reflectAttribute) {
that.setAttribute(local, value);
}
} }
}, },
sender: this, sender: this,
......
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