Et2Image: Fix a few more cases where class went wrong

This commit is contained in:
nathan 2024-09-26 11:35:41 -06:00
parent e7ed302ea0
commit a594f77601

View File

@ -55,19 +55,26 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
@property({type: String})
set src(_src)
{
this.classList.forEach(_class =>
{
if(_class.startsWith('bi-'))
{
this.classList.remove(_class);
}
});
this.__src = _src;
let url = this.parse_href(_src) || this.parse_href(this.defaultSrc);
if(!url)
{
// Hide if no valid image
if (this._img) this._img.src = '';
this.className = this.title = '';
return;
}
const bootstrap = url.match(/\/node_modules\/bootstrap-icons\/icons\/([^.]+)\.svg/);
if (bootstrap && !this._img)
{
this.className = 'bi-'+bootstrap[1];
this.classList.add('bi-' + bootstrap[1]);
return;
}
// change between bootstrap and regular img
@ -167,9 +174,6 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM
// set title on et2-image for both bootstrap-image via css-class and embedded img tag
this.title = this.statustext || this.label || "";
this.classList.forEach(_class => {
if (_class.startsWith('bi-')) this.classList.remove(_class);
});
const bootstrap = url.match(/\/node_modules\/bootstrap-icons\/icons\/([^.]+)\.svg/);
if (bootstrap)
{