fix: WCEnd editor modal pre-loads correct colour and errno value

- Default colour now checks dataset.exitError instead of tagName === 'WC-END',
  so success (exit 0) END blocks default to blue, error END blocks to red
- _selectByCode now also sets the HTML value attribute via setAttribute(),
  ensuring cloneNode(true) preserves the formatted display value
- Add 4 regression tests for colour defaults, attribute sync, and clone value
This commit is contained in:
2026-06-23 00:52:56 +02:00
parent 68da5592ef
commit 3657a22125
3 changed files with 61 additions and 3 deletions
+6 -2
View File
@@ -118,11 +118,15 @@ class WCEnd extends WCBlock {
this._selectedCode = code;
const item = this._errnoItems.find(i => i.code === code);
if (item) {
this._el.input.value = code + " " + item.name;
const display = code + " " + item.name;
this._el.input.value = display;
this._el.input.setAttribute("value", display);
this._el.desc.textContent = item.desc;
this.dataset.exitError = code !== 0 ? "true" : "";
} else {
this._el.input.value = code + " error";
const display = code + " error";
this._el.input.value = display;
this._el.input.setAttribute("value", display);
this._el.desc.textContent = "unknown error";
this.dataset.exitError = "true";
}