script: escape html elements in widget log to avoid cyclic json error

This commit is contained in:
jean-emmanuel 2026-03-02 11:20:49 +01:00
parent 3d12e85e56
commit e2c48bd6ac
2 changed files with 6 additions and 1 deletions

View file

@ -56,7 +56,7 @@ class Vm {
this.globals.console = {
...console,
log: (...msg)=>{
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m)
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m, this.jsonReplacer) : m)
this.getWidget().log(msg.join(' '))
}
}
@ -143,6 +143,10 @@ class Vm {
}
jsonReplacer(key, value) {
return value instanceof HTMLElement ? `<${value.tagName}#${value.id}>` : value
}
}
export default Vm