kopia lustrzana https://github.com/shoelace-style/shoelace
Fixes #148 - prevents recursive calls to observer
Uses a block list for the attributes that shouldn't trigger the observer. It may be better to use an allow list since the observer is still called unnecessarily for e.g. `style` attribute changes.pull/149/head
rodzic
c1300ea3d6
commit
8f0c1eb339
|
@ -59,7 +59,15 @@ export class TabGroup {
|
|||
focusVisible.observe(this.tabGroup);
|
||||
|
||||
// Update aria labels if the DOM changes
|
||||
this.mutationObserver = new MutationObserver(() => setTimeout(() => this.setAriaLabels()));
|
||||
this.mutationObserver = new MutationObserver(mutations => {
|
||||
if (
|
||||
mutations.some(mutation => {
|
||||
return !['arial-labeledby', 'aria-controls'].includes(mutation.attributeName);
|
||||
})
|
||||
) {
|
||||
setTimeout(() => this.setAriaLabels());
|
||||
}
|
||||
});
|
||||
this.mutationObserver.observe(this.host, { attributes: true, childList: true, subtree: true });
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue