Skip to content

Commit

Permalink
fix: esl-alert target attribute change observation fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Feb 18, 2021
1 parent 514e50c commit 5226c96
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/modules/esl-alert/core/esl-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class ESLAlert extends ESLToggleable {
static is = 'esl-alert';
static eventNs = 'esl:alert';

static get observedAttributes() { return ['target']; }

static defaultConfig: AlertActionParams = {
hideDelay: 2500
};
Expand All @@ -46,6 +48,13 @@ export class ESLAlert extends ESLToggleable {
return Object.assign({}, type.defaultConfig, this.defaultParams || {}, params || {});
}

protected attributeChangedCallback(attrName: string, oldVal: string, newVal: string) {
if (!this.connected) return;
if (attrName === 'target') {
this.$target = TraversingQuery.first(this.target) as EventTarget;
}
}

protected connectedCallback() {
super.connectedCallback();
this.render();
Expand Down Expand Up @@ -90,8 +99,8 @@ export class ESLAlert extends ESLToggleable {
}

protected onShow(params: AlertActionParams) {
CSSUtil.addCls(this, params.cls);
if (params.text || params.html) {
CSSUtil.addCls(this, params.cls);
if (params.text) {
this.$text.textContent = params.text;
} else if (params.html) {
Expand Down

0 comments on commit 5226c96

Please sign in to comment.