diff --git a/packages/provider/src/adapter-lit-element.js b/packages/provider/src/adapter-lit-element.js index e457983ade9f9536a6b23d00c5d20c570525d536..53ca6a106bb392c8c3e700dedf4d2d94d263d62c 100644 --- a/packages/provider/src/adapter-lit-element.js +++ b/packages/provider/src/adapter-lit-element.js @@ -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() { diff --git a/packages/provider/src/provider.js b/packages/provider/src/provider.js index 49249d3905c0afa7c73631bcbafab2a43c3bde9d..b213edbef389fac1f9e2ef143cacb1722039dddb 100644 --- a/packages/provider/src/provider.js +++ b/packages/provider/src/provider.js @@ -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]) {