From 099b5cbed872e32a2fbe6b323d2741290edd8a2c Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 24 May 2024 11:48:04 +0400 Subject: [PATCH] Update selector view on attribute id change. Closes #5882 --- src/dom_components/model/Component.ts | 6 +++++- src/selector_manager/view/ClassTagsView.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dom_components/model/Component.ts b/src/dom_components/model/Component.ts index 1804261c9..584b62dc7 100644 --- a/src/dom_components/model/Component.ts +++ b/src/dom_components/model/Component.ts @@ -550,7 +550,11 @@ export default class Component extends StyleableModel { const attrPrev = { ...this.previous('attributes') }; const diff = shallowDiff(attrPrev, this.get('attributes')!); - keys(diff).forEach(pr => this.trigger(`change:attributes:${pr}`, this, diff[pr], opts)); + keys(diff).forEach(pr => { + const attrKey = `attributes:${pr}`; + this.trigger(`change:${attrKey}`, this, diff[pr], opts); + this.em?.trigger(`${keyUpdate}:${attrKey}`, this, diff[pr], opts); + }); } /** diff --git a/src/selector_manager/view/ClassTagsView.ts b/src/selector_manager/view/ClassTagsView.ts index 21c727f8a..050752304 100644 --- a/src/selector_manager/view/ClassTagsView.ts +++ b/src/selector_manager/view/ClassTagsView.ts @@ -83,8 +83,9 @@ export default class ClassTagsView extends View { this.em = em; this.componentChanged = debounce(this.componentChanged.bind(this), 0); this.checkSync = debounce(this.checkSync.bind(this), 0); - const toList = 'component:toggled component:update:classes'; - const toListCls = 'component:update:classes change:state'; + const evClsUp = 'component:update:classes'; + const toList = `component:toggled ${evClsUp}`; + const toListCls = `${evClsUp} component:update:attributes:id change:state`; this.listenTo(em, toList, this.componentChanged); this.listenTo(em, 'styleManager:update', this.componentChanged); this.listenTo(em, toListCls, this.__handleStateChange);