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

Don't use parent for events and add attribute warning (dbp/apps/library#77)

parent d1ef1625
No related branches found
No related tags found
No related merge requests found
Pipeline #15597 passed
......@@ -46,13 +46,21 @@ export class AdapterLitElement extends LitElement {
detail: {
name: global,
callback: (value) => {
console.log('AdapterLitElement(' + this.tagName + ') sub/Callback ' + global + ' -> ' + local + ' = ' + value);
this.attributeChangedCallback(local, that[local], value);
console.log('AdapterLitElement(' + that.tagName + ') sub/Callback ' + global + ' -> ' + local + ' = ' + value);
that.attributeChangedCallback(local, that[local], value);
// we don't support attributes and provider values at the same time
if (that.getAttribute(local) !== null) {
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
// that.setAttribute(local, value);
}
},
sender: this,
}
});
this.parentElement.dispatchEvent(event);
this.dispatchEvent(event);
}
unSubscribeProviderFor(element) {
......@@ -68,7 +76,7 @@ export class AdapterLitElement extends LitElement {
sender: this,
}
});
this.parentElement.dispatchEvent(event);
this.dispatchEvent(event);
}
static get properties() {
......
......@@ -42,8 +42,7 @@ export class Provider extends HTMLElement {
console.log('Provider(' + this.id() + ') connectedCallback()');
const that = this;
const parent = this.parentElement;
parent.addEventListener('inherit', function (e) {
this.addEventListener('inherit', function (e) {
if (that[e.detail.name]) {
console.log('Provider(' + that.id() + ') eventListener("inherit",..) name "' + e.detail.name + '" found.');
//console.dir(e.detail);
......@@ -52,7 +51,7 @@ export class Provider extends HTMLElement {
}
}, false);
parent.addEventListener('subscribe', function (e) {
this.addEventListener('subscribe', function (e) {
const name = e.detail.name;
if (that[name]) {
console.log('Provider(' + that.id() + ') eventListener("subscribe",..) name "' + name + '" found.');
......@@ -63,7 +62,7 @@ export class Provider extends HTMLElement {
}
}, false);
parent.addEventListener('unsubscribe', function (e) {
this.addEventListener('unsubscribe', function (e) {
const name = e.detail.name;
const sender = e.detail.sender;
if (that[name]) {
......
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