webassembly/library: Make use of CustomEvent detail property.

This changes the CustomEvent for stdout to use the existing `detail`
property of CustomEvent instead of adding a `data` property.

Signed-off-by: David Lechner <david@pybricks.com>
pull/9917/head
David Lechner 2022-11-09 12:27:28 -06:00 zatwierdzone przez Damien George
rodzic 0698dd72ea
commit ea07ab04f8
2 zmienionych plików z 2 dodań i 3 usunięć

Wyświetl plik

@ -70,7 +70,7 @@ something to stdout. The following code demonstrates basic functionality:
<script>
document.addEventListener("micropython-print", function(e) {
let output = document.getElementById("micropython-stdout");
output.innerText += e.data;
output.innerText += e.detail;
}, false);
var mp_js_startup = Module["onRuntimeInitialized"];

Wyświetl plik

@ -33,8 +33,7 @@ mergeInto(LibraryManager.library, {
process.stdout.write(b);
} else {
var c = String.fromCharCode(getValue(ptr + i, 'i8'));
var printEvent = new CustomEvent('micropython-print');
printEvent.data = c;
var printEvent = new CustomEvent('micropython-print', { detail: c });
document.dispatchEvent(printEvent);
}
}