Update seList.js

master
JFH 2021-11-01 18:12:31 +01:00
parent 65dc979c50
commit 2c6503e026
1 changed files with 3 additions and 1 deletions

View File

@ -45,7 +45,7 @@ export class SeList extends HTMLElement {
this._shadowRoot.append(template.content.cloneNode(true)); this._shadowRoot.append(template.content.cloneNode(true));
this.$dropdown = this._shadowRoot.querySelector('elix-dropdown-list'); this.$dropdown = this._shadowRoot.querySelector('elix-dropdown-list');
this.$label = this._shadowRoot.querySelector('label'); this.$label = this._shadowRoot.querySelector('label');
this.$selection = this.$dropdown.shadowRoot.querySelector('#source').querySelector('#value'); this.$selection = this.$dropdown.shadowRoot.querySelector('#value');
this.items = this.querySelectorAll("se-list-item"); this.items = this.querySelectorAll("se-list-item");
this.imgPath = svgEditor.configObj.curConfig.imgPath; this.imgPath = svgEditor.configObj.curConfig.imgPath;
} }
@ -84,8 +84,10 @@ export class SeList extends HTMLElement {
Array.from(this.items).forEach(function (element) { Array.from(this.items).forEach(function (element) {
if(element.getAttribute("value") === newValue) { if(element.getAttribute("value") === newValue) {
if (element.hasAttribute("src")) { if (element.hasAttribute("src")) {
// empty current selection children
while(currentObj.$selection.firstChild) while(currentObj.$selection.firstChild)
currentObj.$selection.removeChild(currentObj.$selection.firstChild); currentObj.$selection.removeChild(currentObj.$selection.firstChild);
// replace selection child with image of new value
const img = document.createElement('img'); const img = document.createElement('img');
img.src = currentObj.imgPath + '/' + element.getAttribute("src"); img.src = currentObj.imgPath + '/' + element.getAttribute("src");
img.style.height = element.getAttribute("img-height"); img.style.height = element.getAttribute("img-height");